Solutions for Class 10 ICSE Logix Kips Computer Applications with BlueJ Java | IT Developer <?php echo $page_title; ?>
IT Developer

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