Created
October 18, 2025 04:39
-
-
Save amalik-poit/05b4c6e840749005a10e662f59cbc562 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| import java.util.Scanner; | |
| public class StudentPercentage { | |
| public static void main(String[] args) { | |
| Scanner input = new Scanner(System.in); | |
| String[] names = new String[10]; | |
| double[] obtainedMarks = new double[10]; | |
| double[] totalMarks = new double[10]; | |
| double[] percentage = new double[10]; | |
| System.out.println("Enter details for 10 students:"); | |
| for (int i = 0; i < 1; i++) { | |
| System.out.println("\nStudent " + (i + 1) + ":"); | |
| System.out.print("Enter name: "); | |
| names[i] = input.nextLine(); | |
| System.out.print("Enter obtained marks: "); | |
| obtainedMarks[i] = input.nextDouble(); | |
| System.out.print("Enter total marks: "); | |
| totalMarks[i] = input.nextDouble(); | |
| input.nextLine(); // to clear buffer | |
| percentage[i] = (obtainedMarks[i] / totalMarks[i]) * 100; | |
| } | |
| System.out.println("\n--- Student Results ---"); | |
| System.out.println("Name\t\tObtained\tTotal\tPercentage"); | |
| for (int i = 0; i < 1; i++) { | |
| System.out.printf("%-10s\t%.2f\t\t%.2f\t%.2f%%\n", | |
| names[i], obtainedMarks[i], totalMarks[i], percentage[i]); | |
| } | |
| input.close(); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment