In this tutorial you will learn about the Passing Division Program in Java and its application with practical example.
In this tutorial, we will learn to create a Java to Program Find Passing Division Program in Java using java programming.
Prerequisites
Before starting with this tutorial, we assume that you are best aware of the following Java programming concepts:
- Java Operators.
- Basic Input and Output function in Java.
- Class and Object in Java.
- Basic Java programming.
- If-else statements in Java.
- For loop in Java.
How to Calculate percentage?
Percent is one out of one hundred parts, i.e., A ratio of the parts out of 100. Symbol of a percent is “%”.
Example :->
Passing Division Program in Java
In this program we will find Passing Division number provided by user. first will take the input from the user and then calculate passing percentage of a user. Lets have look at the Code.
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 |
// java program to calculate passing Divison.. import java.util.Scanner; import java.util.*; public class Passing_Division { public static void main(String[] args) { // Declaring variables and taking values from user at run time.. int m, e, s, art, com, total, per; Scanner sc = new Scanner(System.in); System.out.println("Enter marks out of 100"); System.out.print("Enter math marks= "); m = sc.nextInt(); System.out.print("Enter English marks= "); e = sc.nextInt(); System.out.print("Enter science marks= "); s = sc.nextInt(); System.out.print("Enter art marks= "); art = sc.nextInt(); System.out.print("Enter computer marks= "); com = sc.nextInt(); total = m + e + s + art + com; System.out.println("Total marks out of 500=" + total); per = total / 5; System.out.println("Percent of marks=" + per); if (per < 33) { System.out.println("Fail"); } else if ((per >= 33) && (per < 45)) { System.out.println("Third Division"); } else if ((per >= 45) && (per < 60)) { System.out.println("Second Division"); } else { System.out.println("First Division"); } } } |
Output
Division:=>
In the above program, we have first declared and initialized a set variables required in the program.
- m = it will hold entered math’s number.
- e = it will hold entered English number.
- s = it will hold entered science number.
- art = it will hold entered art number.
- com = it will hold entered computer number.
- total= it will hold total of all subject.
- per =it will hold percentage of a student.
After that we take 5 subjects values form user.
and then after that we add all values in variable total and
then after find percentage
and finally we will print the percentage according to inputted values.