Knowee
Questions
Features
Study Tools

In an online electric bill system to pay bill, create a class ‘Consumer’ and get the name, consumer number, address, last date for payment, current date and penalty-per-day information. For ‘consumer number’ create user defined exception class and check if it is a negative number and print “Enter correct data”.Calculate the total penalty as (days* penalty-per-day). If the total number of days exceeded 5 handle the exception and print “Not permitted”. (days=current date-last date for payment)If the name entered contains numbers or any special characters (other than alphabets and spaces), then handle it using exception handling and print “Enter correct name”. InputGet the following detailsName (String)Consumer Number (Integer)Address (String)yyyy-mm-dd (last date) (String)yyyy-mm-dd (current date) (String) Penalty in Rs. per day (Integer)outputuser defined string according to the exception occured

Question

In an online electric bill system to pay bill, create a class ‘Consumer’ and get the name, consumer number, address, last date for payment, current date and penalty-per-day information. For ‘consumer number’ create user defined exception class and check if it is a negative number and print “Enter correct data”.Calculate the total penalty as (days* penalty-per-day). If the total number of days exceeded 5 handle the exception and print “Not permitted”. (days=current date-last date for payment)If the name entered contains numbers or any special characters (other than alphabets and spaces), then handle it using exception handling and print “Enter correct name”. InputGet the following detailsName (String)Consumer Number (Integer)Address (String)yyyy-mm-dd (last date) (String)yyyy-mm-dd (current date) (String) Penalty in Rs. per day (Integer)outputuser defined string according to the exception occured

...expand
🧐 Not the exact question you are looking for?Go ask a question

Solution

Here is a Python code that implements the requirements:

import datetime
import re

class NegativeNumberException(Exception):
    pass

class InvalidNameException(Exception):
    pass

class NotPermittedException(Exception):
    pass

class Consumer:
    def __init__(self, name, consumer_number, address, last_date, current_date, penalty_per_day):
        self.name = name
        self.consumer_number = consumer_number
        self.address = address

This problem has been solved

Similar Questions

In a College student needs to pay fee, create a class ‘Student’ and get the name, age, Department, Last date for fee payment, current date and Penalty-per-day information. For ‘age’ create user defined exception class and check if age is a negative number and print “Please enter correct age”. Calculate the total penalty as days* penalty-per-day. If the total number of days exceeded 5 handle the exception and print “Not Permitted”.If the name entered is not a string, then handle it using exception handling and print “Enter your Correct Name”. Input:Anne18CSE2022-10-05(last date)2022-10-12(current date)2000(penalty per day)OutputNot Permitted

A person needs to pay Life Insurance Premium, create a class ‘Person’ and get the name, age, Premium Number, Last date for Premium payment, current date and Penalty-per-day information.For ‘age’ create user defined exception class and check if age is a negative number and print “Please enter correct age”.Calculate the total penalty, as days* penalty-per-day. If the total number of days exceeded 5 handle the exception and print “Not Permitted”.If the name entered is not a string, then handle it using exception handling and print “Enter your Correct Name”.Input:Anne18LC7892532022-10-05(last date)2022-10-12(current date)2000(penalty per day)OutputNot Permitted

In a Library Management System, create a class ‘LibUser’ and get the name, age, address, book name, book type, date of issue, date of return (current date) and penalty amount. For ‘age’ create user defined exception class and check if age is a negative number and print “Please enter correct age”.Calculate the number of days of book in use as (current date - date of issue). If number of days of book in use is greater than 15 days and then handle the exception and print “Fine to be paid + Penalty amount”. Penalty amount = (number of days of book in use – 15) * 10.If the name entered contains numbers or any special characters (other than alphabets and spaces), then handle it using exception handling and print “Enter your Correct Name”.InputName (String)Age (Integer)address (String)book name (String)book type (String)date of issue (format: yyyy-mm-dd) (String)Current date (format: yyyy-mm-dd) (String)OutputUser defined string according to exception

To develop a Java application to generate Electricity bill. Create a class with the following members: Consumer no., consumer name, previous month reading, current month reading, type of EB connection (i.e domestic or commercial). Compute the bill amount using the following tariff. If the type of the EB connection is domestic, calculate the amount to be paid as follows:First 100 units - Rs. 1 per unit101-200 units - Rs. 2.50 per unit201 -500 units - Rs. 4 per unit> 501 units - Rs. 6 per unitIf the type of the EB connection is commercial, calculate the amount to be paid as follows:First 100 units - Rs. 2 per unit101-200 units - Rs. 4.50 per unit201 -500 units - Rs. 6 per unit> 501 units - Rs. 7 per unitSample:InputEnter consumer number 1001Enter Type of connection (D for Domestic or C for Commercial) DEnter consumer name  SachinEnter previous month reading 3000Enter current month reading 4000OutputConsumer number = 1001Consumer name = Sachintype of connection = DOMESTICCurrent Month Reading = 4000.0Previous Month Reading = 3000.0Total units = 1000.0Total bill = RS 6000.0

Experiment 1 PROGRAM TO GENERATE ELECTRICITY BILL AIM To develop a Java application to generate Electricity bill. PROCEDURE 1.Create a class with the following members Consumer no., consumer name, previous month reading, current month reading, type of EB connection (i.e domestic or commercial). 2.Compute the bill amount using the following tarif…

1/1

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.