Programming Shortcut

Write, Run and execute Your programs with simple and esay way by Programming Shortcut

Tuesday, October 31, 2017

Find grade of a student according to marks in Java

Hello friends! Welcome to my website

Today we run java programming to find out the grade of a student when the marks of 6 subjects are given.
The method of assigning grade is -
percentage>=85 grade=A
percentage=70 grade=B
percentage=55 grade=C
percentage=40 grade=D
percentagegrade=E

This java language programming is free all type of errors like the compiler and runtime errors and this programming is tested to compile and then run the program code.
Here is only programming code with the output. This programming output is customized to understand easily.

Find grade of a student according to their percentage in java programming

import java.util.Scanner;

class test2 {
    double m1, m2, m3, m4, m5, m6;
    String grade, name;
    public void Getgrade(double m1,double m2,double m3,double m4,double m5,double m6,String grade,String name) {
        double pre, total;
//total Maarks of all subject
        total = m1 + m2 + m3 + m4 + m5 + m6;
//calculate precentage of marks
        pre = total / 6;
//contdtion to check pass or not
        if (pre > 33) {
// contdtion for grade A
            if (pre >= 85) {
                grade = "A";
                System.out.println(name+" passed with "+grade+" Grade and "+pre+"%");
            }
// contdtion for grade B
            else if (pre >= 70) {
                grade = "B";
                System.out.println(name+" passed with "+grade+" Grade and "+pre+"%");
            }
// contdtion for grade C
            else if (pre >= 55) {
                grade = "C";
                System.out.println(name+" passed with "+grade+" Grade and "+pre+"%");
            }
// contdtion for grade D
            else if (pre >= 40) {
                grade = "D";
                System.out.println(name+" passed with "+grade+" Grade and "+pre+"%");
            }
// contdtion for grade E
            else {
                grade = "E";
                System.out.println(name+" passed with "+grade+" Grade and "+ pre+"%");
            }
        }
        else {
            System.out.println(name +" is fail in  exam, Score only "+pre+"%");
        }
    }
}

public class grade {
    public static void main(String[] args) {
        test2 o = new test2();
        Scanner c = new Scanner(System.in);
        System.out.print("Please Enter the Student Name:");
        o.name = c.nextLine();
        System.out.print("enter all the marks of " + o.name + ": ");
        o.m1 = c.nextInt();
        o.m2 = c.nextInt();
        o.m3 = c.nextInt();
        o.m4 = c.nextInt();
        o.m5 = c.nextInt();
        o.m6 = c.nextInt();
        o.Getgrade(o.m1, o.m2, o.m3, o.m4, o.m5, o.m6, o.grade, o.name);
    }
}


Output:
         Please Enter the Student Name:Abcd
enter all the marks of Abcd: 75
74
45
89
100
99
Abcd passed with B Grade and 80.33333333333333%

I make this programming and hope you are like the post if are you like the post you can please comment and Share the post to reach more people.
If any doubt about this Java programming code or input & output please comment below
If you have another question about Java programming send an email by contacting us form are given on the page right side.

Please share your experience about this post,
Thank You!
Newer Post Older Post Home
");

Programming Shortcut is collections in java best programs with example, best c programs with example and best c++ programs with example, best way to learn java, c and c++

About Programming Shortcut

This is a programming learning website that can help you learn and when your write your programming code. And all programming code is compiled run programming code in the following programming language C, c++, Java, php and Javascript Languages. find your programming read, understand the programming then copy and past and run your program and save your golden time to typing the program becuse you learn more in leas time. All Programming is codeing is ease to understand the programming