- Home
- Chapter 1 - Object Oriented Programming Concepts
- Object Oriented Programming Concepts
- Multiple Choice Questions
- State whether the given statements are True or False
- Assignment Questions
- Chapter 2 - Introduction to Java
- Introduction to Java
- Multiple Choice Questions
- Assignment Questions
- Chapter 3 - Values and Data Types
- Values and Data Types
- Multiple Choice Questions
- State whether the given statements are True or False
- Assignment Questions
- Chapter 4 - Operators in Java
- Operators in Java
- Multiple Choice Questions
- State whether the given statements are True or False
- Assignment Questions
- Chapter 5 - User-Defined Methods
- User-Defined Methods
- Multiple Choice Questions
- State whether the given statements are True or False
- Assignment Questions
- Chapter 6 - Input in Java
- Input in Java
- Multiple Choice Questions
- Assignment Questions and Programs
- Chapter 7 - Mathematical Library Methods
- Mathematical Library Methods
- Multiple Choice Questions
- Assignment Questions
- Chapter 8 - Conditional Constructs in Java
- Conditional Constructs in Java
- Multiple Choice Questions
- Assignment Questions and Programs
- Chapter 9 - Iterative Constructs in Java
- Iterative Constructs in Java
- Multiple Choice Questions
- State whether the given statements are True or False
- Assignment Questions and Programs
- Chapter 10 - Nested for loops
- Nested for loops
- Assignment Questions and Programs
- Chapter 11 - Constructors
- Constructors
- Multiple Choice Questions
- Assignment Questions and Programs
- Chapter 12 - Library Classes
- Library Classes
- Multiple Choice Questions
- Assignment Questions
- Chapter 13 - Encapsulation and Inheritance
- Library Classes
- Multiple Choice Questions
- Assignment Questions
- Chapter 14 - Arrays
- Library Classes
- Multiple Choice Questions
- Assignment Questions
- Chapter 15 - String Handling
- Library Classes
- Multiple Choice Questions
- Assignment Questions
Conditional Constructs in Java
Chapter 8
Conditional Constructs in Java
Class 10 - Logix Kips ICSE Computer Applications with BlueJ
![]() Share with a Friend |
Java Program: Student Marks, Percentage and Grade Calculator
32. Write a Java program in which you input students name, class, roll number, and marks in 5 subjects. Find out the total marks, percentage, and grade according to the following table.
|
Percentage |
Grade |
|
>=90 |
A+ |
|
>=80 and <90 |
A |
|
>=70 and <80 |
B+ |
|
> =60 and <70 |
B |
|
>=50 and <60 |
C |
|
>=40 and <50 |
D |
|
<40 |
E |
import java.util.Scanner;
public class StudentResult {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String name, studentClass, grade;
int roll;
int total = 0;
double percentage;
System.out.print("Enter Student Name: ");
name = sc.nextLine();
System.out.print("Enter Class: ");
studentClass = sc.nextLine();
System.out.print("Enter Roll Number: ");
roll = sc.nextInt();
System.out.println("Enter marks in 5 subjects:");
for (int i = 1; i <= 5; i++) {
System.out.print("Subject " + i + ": ");
total += sc.nextInt();
}
percentage = total / 5.0;
if (percentage >= 90)
grade = "A+";
else if (percentage >= 80)
grade = "A";
else if (percentage >= 70)
grade = "B+";
else if (percentage >= 60)
grade = "B";
else if (percentage >= 50)
grade = "C";
else if (percentage >= 40)
grade = "D";
else
grade = "E";
System.out.println("\n--- Student Result ---");
System.out.println("Name : " + name);
System.out.println("Class : " + studentClass);
System.out.println("Roll No. : " + roll);
System.out.println("Total Marks: " + total);
System.out.println("Percentage : " + percentage + "%");
System.out.println("Grade : " + grade);
sc.close();
}
}
Output
Sample Output Enter Student Name: Rahul Sharma Enter Class: 10 Enter Roll Number: 15 Enter marks in 5 subjects: Subject 1: 85 Subject 2: 90 Subject 3: 78 Subject 4: 88 Subject 5: 80 --- Student Result --- Name : Rahul Sharma Class : 10 Roll No. : 15 Total Marks: 421 Percentage : 84.2% Grade : A
📝 Explanation
- Uses Scanner class for input
- Marks are summed using a loop
- Percentage = Total ÷ 5
- Grade assigned using if–else ladder
- Output formatted like a marksheet
