0% found this document useful (0 votes)
24 views2 pages

Student Report Card

The document contains a Java program for a Student Report Card system. It allows users to input student details, calculates total marks, average, and assigns a grade based on the average. Finally, it displays the student's report card with all the relevant information.

Uploaded by

shaiba wahab
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views2 pages

Student Report Card

The document contains a Java program for a Student Report Card system. It allows users to input student details, calculates total marks, average, and assigns a grade based on the average. Finally, it displays the student's report card with all the relevant information.

Uploaded by

shaiba wahab
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

import java.util.

Scanner;

public class StudentReportCard {


String name;
int rollNo;
int[] marks = new int[3];
int total;
float average;
char grade;

// Method to input student details


void inputDetails() {
Scanner input = new Scanner(System.in);

System.out.print("Enter student name: ");


name = input.nextLine();

System.out.print("Enter roll number: ");


rollNo = input.nextInt();

for (int i = 0; i < marks.length; i++) {


System.out.print("Enter marks for Subject " + (i + 1) + ": ");
marks[i] = input.nextInt();
}

input.close();
}

// Method to calculate total, average, and grade


void calculateResults() {
total = 0;
for (int i = 0; i < marks.length; i++) {
total += marks[i];
}
average = (float) total / marks.length;

if (average >= 90) {


grade = 'A';
} else if (average >= 80) {
grade = 'B';
} else if (average >= 70) {
grade = 'C';
} else if (average >= 60) {
grade = 'D';
} else {
grade = 'F';
}
}

// Method to display report card


void displayReportCard() {
System.out.println("\n----- Report Card -----");
System.out.println("Name: " + name);
System.out.println("Roll Number: " + rollNo);
for (int i = 0; i < marks.length; i++) {
System.out.println("Marks in Subject " + (i + 1) + ": " + marks[i]);
}
System.out.println("Total Marks: " + total);
System.out.println("Average Marks: " + average);
System.out.println("Grade: " + grade);
}

// Main method
public static void main(String[] args) {
StudentReportCard student = new StudentReportCard();
student.inputDetails();
student.calculateResults();
student.displayReportCard();
}
}

You might also like