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
Question
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
Solution
Here is a Python code that implements the requirements:
import datetime
class AgeException(Exception):
pass
class Student:
def __init__(self, name, age, department, last_date, current_date, penalty_per_day):
try:
if not isinstance(name, str):
raise ValueError("Enter your Correct Name")
if age < 0:
raise AgeException("Please
Similar Questions
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
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
Assume that you are in the process of storing the student details of a University in a file. Code a Java application to handle the following members,Student Register Number - StringStudent Name - StringAge – IntegerGetstudents method to write details on the filePrintstudents method to display the details of the studentsIf the student age is less than 17, display a message that “Invalid Age”. Handle this exception in a proper way using one of the exception keyword.Consider storing three student details and display them.
write a java program Create a class called “Student” with the following details: Name (should contain only alphabets –No numbers and special characters) Register Number in the format (two numbers three characters four numbers) Age (should be greater than 18 and less than 21) Phone number (10 numbers). Write appropriate Exception handling block (separate block for each type of user defined exception) to handle invalid data entry for all data items. If the valid data is entered construct the email id and password of the student and display Email ID format: first name four-digit year @ vitstudent.ac.in and password is “uppercase of first four characters of name + last four numbers of register number+@” Input Format Enter Name: Enter Reg. Number: Enter Age: Enter Phone Number: Output Format Aditya 19BCE1234 20 1234567890
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.