Java Practice Project [Calculating Percentage of Students]


This is a Java Practice Project. In this Project, We will calculate Percentage.


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package com.xdroiddev.datatypes;

import java.util.Scanner;

public class ChanllengeProject {
    public static void main(String[] args) {
        System.out.println("Enter Total Marks to Calculate Percentage :");
        Scanner scan = new Scanner(System.in);
        float full = scan.nextFloat();

        System.out.println("Enter the Number you Got in First Subject:");
        Scanner scan1 = new Scanner(System.in);
        float sub1 = scan1.nextFloat();

        System.out.println("Enter the Number you Got in Second Subject:");
        Scanner scan2 = new Scanner(System.in);
        float sub2 = scan2.nextFloat();

        System.out.println("Enter the Number you Got in Third Subject:");
        Scanner scan3 = new Scanner(System.in);
        float sub3 = scan3.nextFloat();

        System.out.println("Enter the Number you Got in Fourth Subject:");
        Scanner scan4 = new Scanner(System.in);
        float sub4 = scan4.nextFloat();

        System.out.println("Enter the Number you Got in Fifth Subject:");
        Scanner scan5 = new Scanner(System.in);
        float sub5 = scan5.nextFloat();

        float total = sub1 + sub2 + sub3 + sub4 + sub5;
        System.out.println(total + " out of " + full);
        System.out.println("Press 1 to Calculate your Percentage");
        Scanner press = new Scanner(System.in);
        int calculate = press.nextInt();

        switch (calculate) {
            case 1:
                float marks = total / full;
                float percent = marks * 100;
                System.out.println("You Got " + percent + "%");
                break;

            default:
                System.out.println("Out of Index Try Again with Correct Information");

        }

    }

}

Post a Comment

0 Comments