-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5a65457
commit fad0636
Showing
1 changed file
with
22 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import java.util.Scanner; | ||
|
||
public class Percentage { | ||
public static void main(String[] args) { | ||
Scanner scanner = new Scanner(System.in); // Create Scanner object | ||
|
||
System.out.println("This Program is For calculating % of students:"); | ||
System.out.println("Enter first subject no.: "); | ||
float a = scanner.nextFloat(); // Read user input | ||
System.out.println("Enter second subject marks"); | ||
Float b = scanner.nextFloat(); | ||
System.out.println("The above marks you entered are from"); | ||
float total_marks = scanner.nextFloat(); | ||
System.out.println("of how many subject percentage you want to calculate"); | ||
float no_ofsubejcts= scanner.nextFloat(); | ||
float sum_of_marks = a+b; | ||
float calculation_marks= total_marks*no_ofsubejcts; | ||
float Percentage_calc = (sum_of_marks/calculation_marks)*100; | ||
System.out.printf("The percentage is: %.2f%%\n", Percentage_calc); //format specifier is used here %.2f%% | ||
scanner.close(); // Close the scanner | ||
} | ||
} |