Input the Student Indexno,Name,subjects in java

  1. Display the Student details
  2. Display the the max marks
  3. Display the total,average and grade
  4. Exit

Please select one option

import java.util.Scanner;

public class Student {
    public void Main(String args[])
    {

        Scanner scan = new Scanner(System.in);

        System.out.print("Enter Student Index No : ");
        String IndexNo = scan.next();

        System.out.print("Enter Student Name : ");
        String name = scan.next();

        System.out.print("Enter Number of Subjects : ");
        int number_of_subjects = scan.nextInt();
        System.out.println();

        int marks = 0;
        int max = 0;
        int tot = 0;

        for (int a = 0; a < number_of_subjects; a++)
        {
            System.out.print("Enter Subject " + (a + 1) + " Marks : ");
            marks = scan.nextInt();
            if (max < marks) {
                max = marks;
            }
            tot = tot + marks;
        }

        boolean b = true;
        while (b) {
            System.out.println();
            System.out.println("A. Display Student Details.");
            System.out.println("B. Display Maximum Marks.");
            System.out.println("C. Display Total, Average & Result.");
            System.out.println("X. Exit.");
            System.out.println();
            System.out.print("select one option Here : ");
            String option = scan.next();
            System.out.println();
            switch (option) {
                case "A":
                    System.out.println("Student IndexNo : " + IndexNo);
                    System.out.println("Student Name : " + name);

                    break;
                case "B":
                    System.out.println("Maximum Marks : " + max);
                    break;
                case "C":
                    double avg = tot / (double) number_of_subjects;
                    String grade = "Fail";
                    if (avg >= 50) {
                        grade = "Pass";
                    }
                    System.out.println("Your Total : " + tot);
                    System.out.println(" Your Average : " + avg);
                    System.out.println("Your Grade : " + grade);
                    break;
                case "X":
                    System.out.println("Exit");
                    b = false;
                    break;
                default:
                    System.out.println("Please select valid option.");
            }
        }
    }
}

i have attached the video link below. which will do this tutorials step by step

admin

Share
Published by
admin

Recent Posts

Java Beans

A Java Bean is a reusable software component that follows a specific set of conventions.…

19 hours ago

Java String Methods

Java provides a rich set of built-in methods for handling String operations efficiently. Since strings…

20 hours ago

Java Developer Jobs

Java remains one of the most in-demand programming languages worldwide, powering everything from enterprise applications…

20 hours ago

Converting Integer to String in Java

Java provides multiple ways to convert an integer (int) to a string (String). Whether you're…

20 hours ago

JSP to JSP Communication: A Complete Guide to Dynamic Java Web Development

Java Server Pages (JSP) is a powerful technology used to develop dynamic web applications by…

6 days ago

Which Frontend Framework to Use with Spring Boot?

Spring Boot is a powerful backend framework for developing Java-based web applications. Pairing it with…

7 days ago