Design a Student Mark List Generation System using Java.Define a class to store student's register number, name,attendance percentage and an integer array to store five subject marks.Define methods to read and print the student's details. Generate "InvalidMarksException: Marks must be within the range 0 to 30" , If the marks entered are less than 0 or greater than 30. Generate “InsufficientAttendanceException: Minimum Attendance Required is 75%” , if the attendance is less than 75%. Print the marklist only if there are no exceptions generated.Input FormatRegno – intName – StringAttendance – doubleMark1, Mark2, Mark3, Mark4, Mark5 – int Array elementsOutput FormatIf Exception is generated, display the message thrown by theException.Else, display the student details as shown below.Regno:Name:Attendance:Mark1:Mark2:Mark3:Mark4:Mark5:
Question
Design a Student Mark List Generation System using Java.Define a class to store student's register number, name,attendance percentage and an integer array to store five subject marks.Define methods to read and print the student's details. Generate "InvalidMarksException: Marks must be within the range 0 to 30" , If the marks entered are less than 0 or greater than 30. Generate “InsufficientAttendanceException: Minimum Attendance Required is 75%” , if the attendance is less than 75%. Print the marklist only if there are no exceptions generated.Input FormatRegno – intName – StringAttendance – doubleMark1, Mark2, Mark3, Mark4, Mark5 – int Array elementsOutput FormatIf Exception is generated, display the message thrown by theException.Else, display the student details as shown below.Regno:Name:Attendance:Mark1:Mark2:Mark3:Mark4:Mark5:
Solution
Here is a simple implementation of the Student Mark List Generation System in Java:
import java.util.Scanner;
class InvalidMarksException extends Exception {
InvalidMarksException(String s) {
super(s);
}
}
class InsufficientAttendanceException extends Exception {
InsufficientAttendanceException(String s) {
super(s);
}
}
class Student {
int regno;
String name;
double attendance;
int[] marks = new int[5];
void read() {
Scanner sc = new Scanner(System.in);
System.out.println("Enter Regno:");
regno = sc.nextInt();
System.out.println("Enter Name:");
name = sc.next();
System.out.println("Enter Attendance:");
attendance = sc.nextDouble();
System.out.println("Enter Marks:");
for (int i = 0; i < 5; i++) {
marks[i] = sc.nextInt();
}
}
void print() {
System.out.println("Regno: " + regno);
System.out.println("Name: " + name);
System.out.println("Attendance: " + attendance);
for (int i = 0; i < 5; i++) {
System.out.println("Mark" + (i + 1) + ": " + marks[i]);
}
}
void validate() throws InvalidMarksException, InsufficientAttendanceException {
if (attendance < 75) {
throw new InsufficientAttendanceException("Minimum Attendance Required is 75%");
}
for (int i = 0; i < 5; i++) {
if (marks[i] < 0 || marks[i] > 30) {
throw new InvalidMarksException("Marks must be within the range 0 to 30");
}
}
}
}
public class Main {
public static void main(String[] args) {
Student s = new Student();
s.read();
try {
s.validate();
s.print();
} catch (InvalidMarksException | InsufficientAttendanceException e) {
System.out.println(e.getMessage());
}
}
}
This program defines a Student class with fields for the student's register number, name, attendance percentage, and an array for the subject marks. It also defines methods to read and print the student's details. The validate method checks if the attendance is less than 75% and if the marks are within the range 0 to 30. If these conditions are not met, it throws the appropriate exceptions. The main method creates a Student object, reads the student's details, validates them, and prints them if there are no exceptions.
Similar Questions
Develop the Internal mark calculation system based on the attendance percentage using Java. Get the student name, register number, total number of working days in the semester and Number of days present. Calculate attendance percentage of the students and award attendance mark based on the following condition. Attendance percentage >=90 – 5 MarksAttendance percentage >=80 and < 90 – 4 MarksAttendance percentage >=75 and < 80 – 3 MarksAttendance percentage < 75 - 0 MarksImplement using inheritance
Java Program To Accept the Marks of a Student and Find the Total Marks and Percentage
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 Python code that ask the user to enter the number of students. After that ask the user to enter a mark for each student using a loop. Save all marks into an empty list using insert() method. Display all marks after finishing data entry.
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.