A few days ago I published an article about making a in Java. I thought I should make this program work if you are having more than 2 subjects, which most of the students have. report card program I forgot to mention, this will also work if you have let’s say 7 subjects, I mean to say this program will accept more than 1 subject and less than or equal to 15. Write a program to take marks of 15 subjects from the user and display the Total, Percentage, Highest Marks, Average, and Remarks. It should also work if the number of subjects is less than 15. Well. looks good. So, starting with formating the old code 😂. Then, I took a variable and asked how many subject are there in total: System.out.println("How many subjects do you have? (Maximum 15, minimum 2)"); int sub_count = sc.nextInt(); A simple condition to make sure the minimum number of subjects should be 2: if (sub_count == 1) { System.out.println("Atleast 2 subjects required"); } Similarly, I made a else condition which will be executed when the number of is more than 15 or less than 2 (also for negative integers, ex- -15, -27): else { System.out.println("Error: Number of subjects should not be more than 15 or not less than 0"); } I added more 14 condition for different inputs, for ex if the number of subjects is 2, this code will be executed: else if (sub_count == 2) { System.out.println("Enter the marks of 2 subjects (out of 100)"); System.out.println("Enter the marks of subject 1:"); int sub1 = sc.nextInt(); System.out.println("Enter the marks of subject 2:"); int sub2 = sc.nextInt(); if (sub1 <= 100 && sub2 <= 100) { // Total int total = sub1 + sub2; System.out.println("Total = " + total + "/200"); // Percentage float percent = (float) total / 200 * 100; System.out.println("Percentage = " + percent + "%"); // Highest Marks if (sub1 > sub2) { System.out.println("Highest marks scored is " + sub1); } else { System.out.println("Highest marks scored is " + sub2); } // Average float avg = (float) total / 2; System.out.println("Average is " + avg); // Remarks if (percent <= 50) { System.out.println("Remarks: You need to work hard!"); } else if (percent >= 80 && percent <= 90) { System.out.println("Remarks: Good Marks :)"); } else if (percent >= 90) { System.out.println("Remarks: Excellent"); } else { System.out.println("Remarks: Good"); } } else { System.out.println("Values are Greator!"); } } I repeated the same code with some minor changes like, if the no. of subjects is 3 I made one more variable for that and stored the value in it: System.out.println("Enter the marks of subject 3"); int sub3 = sc.nextInt(); I added this variable in this condition so that the value should not be greater than 100: if (sub1 <= 100 && sub2 <= 100 && sub3 <= 100) { // Code } Added the third variable in total: int total = sub1 + sub2 + sub3; System.out.println("Total = " + total + "/300"); Same in Percentage: float percent = (float) total / 300 * 100; System.out.println("Percentage = " + percent + "%"); And for the highest marks first I compared the marks of the first two subjects and added the greater one to another variable then, compared the greater of the two with the marks of the third subject: int max1 = Math.max(sub1, sub2); System.out.println("Highest Marks = " + Math.max(max1, sub3)); Same thing with Average: float avg = (float) total / 3; System.out.println("Average is " + avg); Nothing more is changed, the most important in the highest marks, if the no. of subjects is 4 then this how the code of Highest marks will look: int max1 = Math.max(sub1, sub2); int max2 = Math.max(max1, sub3); System.out.println("Highest Marks = " + Math.max(max2, sub4)); Compared the first 2, stored greater one in a variable, compared the variable with subject 3, stored the greater one in and compared it with the fourth subject. Check out this question on StackOverflow to learn more: max2 https://stackoverflow.com/questions/4982210/find-the-max-of-3-numbers-in-java-with-different-data-types This is how the code looks like if the total subjects are 15: else if (sub_count == 15) { System.out.println("Enter the marks of 10 subjects (out of 100)"); System.out.println("Enter the marks of subject 1:"); int sub1 = sc.nextInt(); System.out.println("Enter the marks of subject 2:"); int sub2 = sc.nextInt(); System.out.println("Enter the marks of subject 3"); int sub3 = sc.nextInt(); System.out.println("Enter the marks of subject 4"); int sub4 = sc.nextInt(); System.out.println("Enter the marks of subject 5"); int sub5 = sc.nextInt(); System.out.println("Enter the marks of subject 6"); int sub6 = sc.nextInt(); System.out.println("Enter the marks of subject 7"); int sub7 = sc.nextInt(); System.out.println("Enter the marks of subject 8"); int sub8 = sc.nextInt(); System.out.println("Enter the marks of subject 9"); int sub9 = sc.nextInt(); System.out.println("Enter the marks of subject 10"); int sub10 = sc.nextInt(); System.out.println("Enter the marks of subject 11"); int sub11 = sc.nextInt(); System.out.println("Enter the marks of subject 12"); int sub12 = sc.nextInt(); System.out.println("Enter the marks of subject 13"); int sub13 = sc.nextInt(); System.out.println("Enter the marks of subject 14"); int sub14 = sc.nextInt(); System.out.println("Enter the marks of subject 15"); int sub15 = sc.nextInt(); if (sub1 <= 100 && sub2 <= 100 && sub3 <= 100 && sub4 <= 100 && sub5 <= 100 && sub6 <= 100 && sub7 <= 100 && sub8 <= 100 && sub9 <= 100 && sub10 <= 100 && sub11 <= 100 && sub12 <= 100 && sub13 <= 100 && sub14 <= 100 && sub15 <= 100) { // Total int total = sub1 + sub2 + sub3 + sub4 + sub5 + sub6 + sub7 + sub8 + sub9 + sub10 + sub11 + sub12 + sub13 + sub14 + sub15; System.out.println("Total = " + total + "/1500"); // Percentage float percent = (float) total / 1500 * 100; System.out.println("Percentage = " + percent + "%"); // Highest Marks int max1 = Math.max(sub1, sub2); int max2 = Math.max(max1, sub3); int max3 = Math.max(max2, sub4); int max4 = Math.max(max3, sub5); int max5 = Math.max(max4, sub6); int max6 = Math.max(max5, sub7); int max7 = Math.max(max6, sub8); int max8 = Math.max(max7, sub9); int max9 = Math.max(max8, sub10); int max10 = Math.max(max9, sub11); int max11 = Math.max(max10, sub12); int max12 = Math.max(max11, sub13); int max13 = Math.max(max12, sub14); System.out.println("Highest Marks = " + Math.max(max13, sub15)); // Average float avg = (float) total / 15; System.out.println("Average is " + avg); // Remarks if (percent <= 50) { System.out.println("Remarks: You need to work hard!"); } else if (percent >= 80 && percent <= 90) { System.out.println("Remarks: Good Marks :)"); } else if (percent >= 90) { System.out.println("Remarks: Excellent"); } else { System.out.println("Remarks: Good"); } } else { System.out.println("Values are Greator!"); } } Source code for 15 subjects This is the source code for the extended program: import java.util.Scanner; public class marks { public static void main(String args[]) { try (Scanner sc = new Scanner(System.in)) { System.out.println("How many subjects do you have? (Maximum 15, minimum 2)"); int sub_count = sc.nextInt(); if (sub_count == 1) { System.out.println("Atleast 2 subjects required"); } else if (sub_count == 2) { System.out.println("Enter the marks of 2 subjects (out of 100)"); System.out.println("Enter the marks of subject 1:"); int sub1 = sc.nextInt(); System.out.println("Enter the marks of subject 2:"); int sub2 = sc.nextInt(); if (sub1 <= 100 && sub2 <= 100) { // Total int total = sub1 + sub2; System.out.println("Total = " + total + "/200"); // Percentage float percent = (float) total / 200 * 100; System.out.println("Percentage = " + percent + "%"); // Highest Marks if (sub1 > sub2) { System.out.println("Highest marks scored is " + sub1); } else { System.out.println("Highest marks scored is " + sub2); } // Average float avg = (float) total / 2; System.out.println("Average is " + avg); // Remarks if (percent <= 50) { System.out.println("Remarks: You need to work hard!"); } else if (percent >= 80 && percent <= 90) { System.out.println("Remarks: Good Marks :)"); } else if (percent >= 90) { System.out.println("Remarks: Excellent"); } else { System.out.println("Remarks: Good"); } } else { System.out.println("Values are Greator!"); } } // 3 Subjects else if (sub_count == 3) { System.out.println("Enter the marks of 3 subjects (out of 100)"); System.out.println("Enter the marks of subject 1:"); int sub1 = sc.nextInt(); System.out.println("Enter the marks of subject 2:"); int sub2 = sc.nextInt(); System.out.println("Enter the marks of subject 3"); int sub3 = sc.nextInt(); if (sub1 <= 100 && sub2 <= 100 && sub3 <= 100) { // Total int total = sub1 + sub2 + sub3; System.out.println("Total = " + total + "/300"); // Percentage float percent = (float) total / 300 * 100; System.out.println("Percentage = " + percent + "%"); // Highest Marks int max1 = Math.max(sub1, sub2); System.out.println("Highest Marks = " + Math.max(max1, sub3)); // Average float avg = (float) total / 3; System.out.println("Average is " + avg); // Remarks if (percent <= 50) { System.out.println("Remarks: You need to work hard!"); } else if (percent >= 80 && percent <= 90) { System.out.println("Remarks: Good Marks :)"); } else if (percent >= 90) { System.out.println("Remarks: Excellent"); } else { System.out.println("Remarks: Good"); } } else { System.out.println("Values are Greator!"); } } // 4 Subjects else if (sub_count == 4) { System.out.println("Enter the marks of 4 subjects (out of 100)"); System.out.println("Enter the marks of subject 1:"); int sub1 = sc.nextInt(); System.out.println("Enter the marks of subject 2:"); int sub2 = sc.nextInt(); System.out.println("Enter the marks of subject 3"); int sub3 = sc.nextInt(); System.out.println("Enter the marks of subject 4"); int sub4 = sc.nextInt(); if (sub1 <= 100 && sub2 <= 100 && sub3 <= 100 && sub4 <= 100) { // Total int total = sub1 + sub2 + sub3 + sub4; System.out.println("Total = " + total + "/400"); // Percentage float percent = (float) total / 400 * 100; System.out.println("Percentage = " + percent + "%"); // Highest Marks int max1 = Math.max(sub1, sub2); int max2 = Math.max(max1, sub3); System.out.println("Highest Marks = " + Math.max(max2, sub4)); // Average float avg = (float) total / 4; System.out.println("Average is " + avg); // Remarks if (percent <= 50) { System.out.println("Remarks: You need to work hard!"); } else if (percent >= 80 && percent <= 90) { System.out.println("Remarks: Good Marks :)"); } else if (percent >= 90) { System.out.println("Remarks: Excellent"); } else { System.out.println("Remarks: Good"); } } else { System.out.println("Values are Greator!"); } // Subject 5 } else if (sub_count == 5) { System.out.println("Enter the marks of 5 subjects (out of 100)"); System.out.println("Enter the marks of subject 1:"); int sub1 = sc.nextInt(); System.out.println("Enter the marks of subject 2:"); int sub2 = sc.nextInt(); System.out.println("Enter the marks of subject 3"); int sub3 = sc.nextInt(); System.out.println("Enter the marks of subject 4"); int sub4 = sc.nextInt(); System.out.println("Enter the marks of subject 5"); int sub5 = sc.nextInt(); if (sub1 <= 100 && sub2 <= 100 && sub3 <= 100 && sub4 <= 100 && sub5 <= 100) { // Total int total = sub1 + sub2 + sub3 + sub4 + sub5; System.out.println("Total = " + total + "/500"); // Percentage float percent = (float) total / 500 * 100; System.out.println("Percentage = " + percent + "%"); // Highest Marks int max1 = Math.max(sub1, sub2); int max2 = Math.max(max1, sub3); int max3 = Math.max(max2, sub4); System.out.println("Highest Marks = " + Math.max(max3, sub5)); // Average float avg = (float) total / 5; System.out.println("Average is " + avg); // Remarks if (percent <= 50) { System.out.println("Remarks: You need to work hard!"); } else if (percent >= 80 && percent <= 90) { System.out.println("Remarks: Good Marks :)"); } else if (percent >= 90) { System.out.println("Remarks: Excellent"); } else { System.out.println("Remarks: Good"); } } else { System.out.println("Values are Greator!"); } // Subject 6 } else if (sub_count == 6) { System.out.println("Enter the marks of 6 subjects (out of 100)"); System.out.println("Enter the marks of subject 1:"); int sub1 = sc.nextInt(); System.out.println("Enter the marks of subject 2:"); int sub2 = sc.nextInt(); System.out.println("Enter the marks of subject 3"); int sub3 = sc.nextInt(); System.out.println("Enter the marks of subject 4"); int sub4 = sc.nextInt(); System.out.println("Enter the marks of subject 5"); int sub5 = sc.nextInt(); System.out.println("Enter the marks of subject 6"); int sub6 = sc.nextInt(); if (sub1 <= 100 && sub2 <= 100 && sub3 <= 100 && sub4 <= 100 && sub5 <= 100 && sub6 <= 100) { // Total int total = sub1 + sub2 + sub3 + sub4 + sub5 + sub6; System.out.println("Total = " + total + "/600"); // Percentage float percent = (float) total / 600 * 100; System.out.println("Percentage = " + percent + "%"); // Highest Marks int max1 = Math.max(sub1, sub2); int max2 = Math.max(max1, sub3); int max3 = Math.max(max2, sub4); int max4 = Math.max(max3, sub5); System.out.println("Highest Marks = " + Math.max(max4, sub6)); // Average float avg = (float) total / 6; System.out.println("Average is " + avg); // Remarks if (percent <= 50) { System.out.println("Remarks: You need to work hard!"); } else if (percent >= 80 && percent <= 90) { System.out.println("Remarks: Good Marks :)"); } else if (percent >= 90) { System.out.println("Remarks: Excellent"); } else { System.out.println("Remarks: Good"); } } else { System.out.println("Values are Greator!"); } // Subject 7 } else if (sub_count == 7) { System.out.println("Enter the marks of 7 subjects (out of 100)"); System.out.println("Enter the marks of subject 1:"); int sub1 = sc.nextInt(); System.out.println("Enter the marks of subject 2:"); int sub2 = sc.nextInt(); System.out.println("Enter the marks of subject 3"); int sub3 = sc.nextInt(); System.out.println("Enter the marks of subject 4"); int sub4 = sc.nextInt(); System.out.println("Enter the marks of subject 5"); int sub5 = sc.nextInt(); System.out.println("Enter the marks of subject 6"); int sub6 = sc.nextInt(); System.out.println("Enter the marks of subject 7"); int sub7 = sc.nextInt(); if (sub1 <= 100 && sub2 <= 100 && sub3 <= 100 && sub4 <= 100 && sub5 <= 100 && sub6 <= 100 && sub7 <= 100) { // Total int total = sub1 + sub2 + sub3 + sub4 + sub5 + sub6 + sub7; System.out.println("Total = " + total + "/700"); // Percentage float percent = (float) total / 700 * 100; System.out.println("Percentage = " + percent + "%"); // Highest Marks int max1 = Math.max(sub1, sub2); int max2 = Math.max(max1, sub3); int max3 = Math.max(max2, sub4); int max4 = Math.max(max3, sub5); int max5 = Math.max(max4, sub6); System.out.println("Highest Marks = " + Math.max(max5, sub7)); // Average float avg = (float) total / 7; System.out.println("Average is " + avg); // Remarks if (percent <= 50) { System.out.println("Remarks: You need to work hard!"); } else if (percent >= 80 && percent <= 90) { System.out.println("Remarks: Good Marks :)"); } else if (percent >= 90) { System.out.println("Remarks: Excellent"); } else { System.out.println("Remarks: Good"); } } else { System.out.println("Values are Greator!"); } // subject 8 } else if (sub_count == 8) { System.out.println("Enter the marks of 8 subjects (out of 100)"); System.out.println("Enter the marks of subject 1:"); int sub1 = sc.nextInt(); System.out.println("Enter the marks of subject 2:"); int sub2 = sc.nextInt(); System.out.println("Enter the marks of subject 3"); int sub3 = sc.nextInt(); System.out.println("Enter the marks of subject 4"); int sub4 = sc.nextInt(); System.out.println("Enter the marks of subject 5"); int sub5 = sc.nextInt(); System.out.println("Enter the marks of subject 6"); int sub6 = sc.nextInt(); System.out.println("Enter the marks of subject 7"); int sub7 = sc.nextInt(); System.out.println("Enter the marks of subject 8"); int sub8 = sc.nextInt(); if (sub1 <= 100 && sub2 <= 100 && sub3 <= 100 && sub4 <= 100 && sub5 <= 100 && sub6 <= 100 && sub7 <= 100 && sub8 <= 100) { // Total int total = sub1 + sub2 + sub3 + sub4 + sub5 + sub6 + sub7 + sub8; System.out.println("Total = " + total + "/800"); // Percentage float percent = (float) total / 800 * 100; System.out.println("Percentage = " + percent + "%"); // Highest Marks int max1 = Math.max(sub1, sub2); int max2 = Math.max(max1, sub3); int max3 = Math.max(max2, sub4); int max4 = Math.max(max3, sub5); int max5 = Math.max(max4, sub6); int max6 = Math.max(max5, sub7); System.out.println("Highest Marks = " + Math.max(max6, sub8)); // Average float avg = (float) total / 8; System.out.println("Average is " + avg); // Remarks if (percent <= 50) { System.out.println("Remarks: You need to work hard!"); } else if (percent >= 80 && percent <= 90) { System.out.println("Remarks: Good Marks :)"); } else if (percent >= 90) { System.out.println("Remarks: Excellent"); } else { System.out.println("Remarks: Good"); } } else { System.out.println("Values are Greator!"); } // subject 9 } else if (sub_count == 9) { System.out.println("Enter the marks of 9 subjects (out of 100)"); System.out.println("Enter the marks of subject 1:"); int sub1 = sc.nextInt(); System.out.println("Enter the marks of subject 2:"); int sub2 = sc.nextInt(); System.out.println("Enter the marks of subject 3"); int sub3 = sc.nextInt(); System.out.println("Enter the marks of subject 4"); int sub4 = sc.nextInt(); System.out.println("Enter the marks of subject 5"); int sub5 = sc.nextInt(); System.out.println("Enter the marks of subject 6"); int sub6 = sc.nextInt(); System.out.println("Enter the marks of subject 7"); int sub7 = sc.nextInt(); System.out.println("Enter the marks of subject 8"); int sub8 = sc.nextInt(); System.out.println("Enter the marks of subject 9"); int sub9 = sc.nextInt(); if (sub1 <= 100 && sub2 <= 100 && sub3 <= 100 && sub4 <= 100 && sub5 <= 100 && sub6 <= 100 && sub7 <= 100 && sub8 <= 100 && sub9 <= 100) { // Total int total = sub1 + sub2 + sub3 + sub4 + sub5 + sub6 + sub7 + sub8 + sub9; System.out.println("Total = " + total + "/900"); // Percentage float percent = (float) total / 900 * 100; System.out.println("Percentage = " + percent + "%"); // Highest Marks int max1 = Math.max(sub1, sub2); int max2 = Math.max(max1, sub3); int max3 = Math.max(max2, sub4); int max4 = Math.max(max3, sub5); int max5 = Math.max(max4, sub6); int max6 = Math.max(max5, sub7); int max7 = Math.max(max6, sub8); System.out.println("Highest Marks = " + Math.max(max7, sub9)); // Average float avg = (float) total / 8; System.out.println("Average is " + avg); // Remarks if (percent <= 50) { System.out.println("Remarks: You need to work hard!"); } else if (percent >= 80 && percent <= 90) { System.out.println("Remarks: Good Marks :)"); } else if (percent >= 90) { System.out.println("Remarks: Excellent"); } else { System.out.println("Remarks: Good"); } } else { System.out.println("Values are Greator!"); } // subject 10 } else if (sub_count == 10) { System.out.println("Enter the marks of 10 subjects (out of 100)"); System.out.println("Enter the marks of subject 1:"); int sub1 = sc.nextInt(); System.out.println("Enter the marks of subject 2:"); int sub2 = sc.nextInt(); System.out.println("Enter the marks of subject 3"); int sub3 = sc.nextInt(); System.out.println("Enter the marks of subject 4"); int sub4 = sc.nextInt(); System.out.println("Enter the marks of subject 5"); int sub5 = sc.nextInt(); System.out.println("Enter the marks of subject 6"); int sub6 = sc.nextInt(); System.out.println("Enter the marks of subject 7"); int sub7 = sc.nextInt(); System.out.println("Enter the marks of subject 8"); int sub8 = sc.nextInt(); System.out.println("Enter the marks of subject 9"); int sub9 = sc.nextInt(); System.out.println("Enter the marks of subject 10"); int sub10 = sc.nextInt(); if (sub1 <= 100 && sub2 <= 100 && sub3 <= 100 && sub4 <= 100 && sub5 <= 100 && sub6 <= 100 && sub7 <= 100 && sub8 <= 100 && sub9 <= 100 && sub10 <= 100) { // Total int total = sub1 + sub2 + sub3 + sub4 + sub5 + sub6 + sub7 + sub8 + sub9 + sub10; System.out.println("Total = " + total + "/1000"); // Percentage float percent = (float) total / 1000 * 100; System.out.println("Percentage = " + percent + "%"); // Highest Marks int max1 = Math.max(sub1, sub2); int max2 = Math.max(max1, sub3); int max3 = Math.max(max2, sub4); int max4 = Math.max(max3, sub5); int max5 = Math.max(max4, sub6); int max6 = Math.max(max5, sub7); int max7 = Math.max(max6, sub8); int max8 = Math.max(max7, sub9); System.out.println("Highest Marks = " + Math.max(max8, sub10)); // Average float avg = (float) total / 10; System.out.println("Average is " + avg); // Remarks if (percent <= 50) { System.out.println("Remarks: You need to work hard!"); } else if (percent >= 80 && percent <= 90) { System.out.println("Remarks: Good Marks :)"); } else if (percent >= 90) { System.out.println("Remarks: Excellent"); } else { System.out.println("Remarks: Good"); } } else { System.out.println("Values are Greator!"); } // subject 11 } else if (sub_count == 11) { System.out.println("Enter the marks of 10 subjects (out of 100)"); System.out.println("Enter the marks of subject 1:"); int sub1 = sc.nextInt(); System.out.println("Enter the marks of subject 2:"); int sub2 = sc.nextInt(); System.out.println("Enter the marks of subject 3"); int sub3 = sc.nextInt(); System.out.println("Enter the marks of subject 4"); int sub4 = sc.nextInt(); System.out.println("Enter the marks of subject 5"); int sub5 = sc.nextInt(); System.out.println("Enter the marks of subject 6"); int sub6 = sc.nextInt(); System.out.println("Enter the marks of subject 7"); int sub7 = sc.nextInt(); System.out.println("Enter the marks of subject 8"); int sub8 = sc.nextInt(); System.out.println("Enter the marks of subject 9"); int sub9 = sc.nextInt(); System.out.println("Enter the marks of subject 10"); int sub10 = sc.nextInt(); System.out.println("Enter the marks of subject 11"); int sub11 = sc.nextInt(); if (sub1 <= 100 && sub2 <= 100 && sub3 <= 100 && sub4 <= 100 && sub5 <= 100 && sub6 <= 100 && sub7 <= 100 && sub8 <= 100 && sub9 <= 100 && sub10 <= 100 && sub11 <= 100) { // Total int total = sub1 + sub2 + sub3 + sub4 + sub5 + sub6 + sub7 + sub8 + sub9 + sub10 + sub11; System.out.println("Total = " + total + "/1100"); // Percentage float percent = (float) total / 1100 * 100; System.out.println("Percentage = " + percent + "%"); // Highest Marks int max1 = Math.max(sub1, sub2); int max2 = Math.max(max1, sub3); int max3 = Math.max(max2, sub4); int max4 = Math.max(max3, sub5); int max5 = Math.max(max4, sub6); int max6 = Math.max(max5, sub7); int max7 = Math.max(max6, sub8); int max8 = Math.max(max7, sub9); int max9 = Math.max(max8, sub10); System.out.println("Highest Marks = " + Math.max(max9, sub11)); // Average float avg = (float) total / 11; System.out.println("Average is " + avg); // Remarks if (percent <= 50) { System.out.println("Remarks: You need to work hard!"); } else if (percent >= 80 && percent <= 90) { System.out.println("Remarks: Good Marks :)"); } else if (percent >= 90) { System.out.println("Remarks: Excellent"); } else { System.out.println("Remarks: Good"); } } else { System.out.println("Values are Greator!"); } // subject 12 } else if (sub_count == 12) { System.out.println("Enter the marks of 10 subjects (out of 100)"); System.out.println("Enter the marks of subject 1:"); int sub1 = sc.nextInt(); System.out.println("Enter the marks of subject 2:"); int sub2 = sc.nextInt(); System.out.println("Enter the marks of subject 3"); int sub3 = sc.nextInt(); System.out.println("Enter the marks of subject 4"); int sub4 = sc.nextInt(); System.out.println("Enter the marks of subject 5"); int sub5 = sc.nextInt(); System.out.println("Enter the marks of subject 6"); int sub6 = sc.nextInt(); System.out.println("Enter the marks of subject 7"); int sub7 = sc.nextInt(); System.out.println("Enter the marks of subject 8"); int sub8 = sc.nextInt(); System.out.println("Enter the marks of subject 9"); int sub9 = sc.nextInt(); System.out.println("Enter the marks of subject 10"); int sub10 = sc.nextInt(); System.out.println("Enter the marks of subject 11"); int sub11 = sc.nextInt(); System.out.println("Enter the marks of subject 12"); int sub12 = sc.nextInt(); if (sub1 <= 100 && sub2 <= 100 && sub3 <= 100 && sub4 <= 100 && sub5 <= 100 && sub6 <= 100 && sub7 <= 100 && sub8 <= 100 && sub9 <= 100 && sub10 <= 100 && sub11 <= 100 && sub12 <= 100) { // Total int total = sub1 + sub2 + sub3 + sub4 + sub5 + sub6 + sub7 + sub8 + sub9 + sub10 + sub11 + sub12; System.out.println("Total = " + total + "/1200"); // Percentage float percent = (float) total / 1200 * 100; System.out.println("Percentage = " + percent + "%"); // Highest Marks int max1 = Math.max(sub1, sub2); int max2 = Math.max(max1, sub3); int max3 = Math.max(max2, sub4); int max4 = Math.max(max3, sub5); int max5 = Math.max(max4, sub6); int max6 = Math.max(max5, sub7); int max7 = Math.max(max6, sub8); int max8 = Math.max(max7, sub9); int max9 = Math.max(max8, sub10); int max10 = Math.max(max9, sub11); System.out.println("Highest Marks = " + Math.max(max10, sub12)); // Average float avg = (float) total / 12; System.out.println("Average is " + avg); // Remarks if (percent <= 50) { System.out.println("Remarks: You need to work hard!"); } else if (percent >= 80 && percent <= 90) { System.out.println("Remarks: Good Marks :)"); } else if (percent >= 90) { System.out.println("Remarks: Excellent"); } else { System.out.println("Remarks: Good"); } } else { System.out.println("Values are Greator!"); } // subject 13 } else if (sub_count == 13) { System.out.println("Enter the marks of 10 subjects (out of 100)"); System.out.println("Enter the marks of subject 1:"); int sub1 = sc.nextInt(); System.out.println("Enter the marks of subject 2:"); int sub2 = sc.nextInt(); System.out.println("Enter the marks of subject 3"); int sub3 = sc.nextInt(); System.out.println("Enter the marks of subject 4"); int sub4 = sc.nextInt(); System.out.println("Enter the marks of subject 5"); int sub5 = sc.nextInt(); System.out.println("Enter the marks of subject 6"); int sub6 = sc.nextInt(); System.out.println("Enter the marks of subject 7"); int sub7 = sc.nextInt(); System.out.println("Enter the marks of subject 8"); int sub8 = sc.nextInt(); System.out.println("Enter the marks of subject 9"); int sub9 = sc.nextInt(); System.out.println("Enter the marks of subject 10"); int sub10 = sc.nextInt(); System.out.println("Enter the marks of subject 11"); int sub11 = sc.nextInt(); System.out.println("Enter the marks of subject 12"); int sub12 = sc.nextInt(); System.out.println("Enter the marks of subject 13"); int sub13 = sc.nextInt(); if (sub1 <= 100 && sub2 <= 100 && sub3 <= 100 && sub4 <= 100 && sub5 <= 100 && sub6 <= 100 && sub7 <= 100 && sub8 <= 100 && sub9 <= 100 && sub10 <= 100 && sub11 <= 100 && sub12 <= 100 && sub13 <= 100) { // Total int total = sub1 + sub2 + sub3 + sub4 + sub5 + sub6 + sub7 + sub8 + sub9 + sub10 + sub11 + sub12 + sub13; System.out.println("Total = " + total + "/1300"); // Percentage float percent = (float) total / 1300 * 100; System.out.println("Percentage = " + percent + "%"); // Highest Marks int max1 = Math.max(sub1, sub2); int max2 = Math.max(max1, sub3); int max3 = Math.max(max2, sub4); int max4 = Math.max(max3, sub5); int max5 = Math.max(max4, sub6); int max6 = Math.max(max5, sub7); int max7 = Math.max(max6, sub8); int max8 = Math.max(max7, sub9); int max9 = Math.max(max8, sub10); int max10 = Math.max(max9, sub11); int max11 = Math.max(max10, sub12); System.out.println("Highest Marks = " + Math.max(max11, sub13)); // Average float avg = (float) total / 13; System.out.println("Average is " + avg); // Remarks if (percent <= 50) { System.out.println("Remarks: You need to work hard!"); } else if (percent >= 80 && percent <= 90) { System.out.println("Remarks: Good Marks :)"); } else if (percent >= 90) { System.out.println("Remarks: Excellent"); } else { System.out.println("Remarks: Good"); } } else { System.out.println("Values are Greator!"); } // subject 14 } else if (sub_count == 14) { System.out.println("Enter the marks of 10 subjects (out of 100)"); System.out.println("Enter the marks of subject 1:"); int sub1 = sc.nextInt(); System.out.println("Enter the marks of subject 2:"); int sub2 = sc.nextInt(); System.out.println("Enter the marks of subject 3"); int sub3 = sc.nextInt(); System.out.println("Enter the marks of subject 4"); int sub4 = sc.nextInt(); System.out.println("Enter the marks of subject 5"); int sub5 = sc.nextInt(); System.out.println("Enter the marks of subject 6"); int sub6 = sc.nextInt(); System.out.println("Enter the marks of subject 7"); int sub7 = sc.nextInt(); System.out.println("Enter the marks of subject 8"); int sub8 = sc.nextInt(); System.out.println("Enter the marks of subject 9"); int sub9 = sc.nextInt(); System.out.println("Enter the marks of subject 10"); int sub10 = sc.nextInt(); System.out.println("Enter the marks of subject 11"); int sub11 = sc.nextInt(); System.out.println("Enter the marks of subject 12"); int sub12 = sc.nextInt(); System.out.println("Enter the marks of subject 13"); int sub13 = sc.nextInt(); System.out.println("Enter the marks of subject 14"); int sub14 = sc.nextInt(); if (sub1 <= 100 && sub2 <= 100 && sub3 <= 100 && sub4 <= 100 && sub5 <= 100 && sub6 <= 100 && sub7 <= 100 && sub8 <= 100 && sub9 <= 100 && sub10 <= 100 && sub11 <= 100 && sub12 <= 100 && sub13 <= 100 && sub14 <= 100) { // Total int total = sub1 + sub2 + sub3 + sub4 + sub5 + sub6 + sub7 + sub8 + sub9 + sub10 + sub11 + sub12 + sub13 + sub14; System.out.println("Total = " + total + "/1400"); // Percentage float percent = (float) total / 1400 * 100; System.out.println("Percentage = " + percent + "%"); // Highest Marks int max1 = Math.max(sub1, sub2); int max2 = Math.max(max1, sub3); int max3 = Math.max(max2, sub4); int max4 = Math.max(max3, sub5); int max5 = Math.max(max4, sub6); int max6 = Math.max(max5, sub7); int max7 = Math.max(max6, sub8); int max8 = Math.max(max7, sub9); int max9 = Math.max(max8, sub10); int max10 = Math.max(max9, sub11); int max11 = Math.max(max10, sub12); int max12 = Math.max(max11, sub13); System.out.println("Highest Marks = " + Math.max(max12, sub14)); // Average float avg = (float) total / 14; System.out.println("Average is " + avg); // Remarks if (percent <= 50) { System.out.println("Remarks: You need to work hard!"); } else if (percent >= 80 && percent <= 90) { System.out.println("Remarks: Good Marks :)"); } else if (percent >= 90) { System.out.println("Remarks: Excellent"); } else { System.out.println("Remarks: Good"); } } else { System.out.println("Values are Greator!"); } // subject 15 } else if (sub_count == 15) { System.out.println("Enter the marks of 10 subjects (out of 100)"); System.out.println("Enter the marks of subject 1:"); int sub1 = sc.nextInt(); System.out.println("Enter the marks of subject 2:"); int sub2 = sc.nextInt(); System.out.println("Enter the marks of subject 3"); int sub3 = sc.nextInt(); System.out.println("Enter the marks of subject 4"); int sub4 = sc.nextInt(); System.out.println("Enter the marks of subject 5"); int sub5 = sc.nextInt(); System.out.println("Enter the marks of subject 6"); int sub6 = sc.nextInt(); System.out.println("Enter the marks of subject 7"); int sub7 = sc.nextInt(); System.out.println("Enter the marks of subject 8"); int sub8 = sc.nextInt(); System.out.println("Enter the marks of subject 9"); int sub9 = sc.nextInt(); System.out.println("Enter the marks of subject 10"); int sub10 = sc.nextInt(); System.out.println("Enter the marks of subject 11"); int sub11 = sc.nextInt(); System.out.println("Enter the marks of subject 12"); int sub12 = sc.nextInt(); System.out.println("Enter the marks of subject 13"); int sub13 = sc.nextInt(); System.out.println("Enter the marks of subject 14"); int sub14 = sc.nextInt(); System.out.println("Enter the marks of subject 15"); int sub15 = sc.nextInt(); if (sub1 <= 100 && sub2 <= 100 && sub3 <= 100 && sub4 <= 100 && sub5 <= 100 && sub6 <= 100 && sub7 <= 100 && sub8 <= 100 && sub9 <= 100 && sub10 <= 100 && sub11 <= 100 && sub12 <= 100 && sub13 <= 100 && sub14 <= 100 && sub15 <= 100) { // Total int total = sub1 + sub2 + sub3 + sub4 + sub5 + sub6 + sub7 + sub8 + sub9 + sub10 + sub11 + sub12 + sub13 + sub14 + sub15; System.out.println("Total = " + total + "/1500"); // Percentage float percent = (float) total / 1500 * 100; System.out.println("Percentage = " + percent + "%"); // Highest Marks int max1 = Math.max(sub1, sub2); int max2 = Math.max(max1, sub3); int max3 = Math.max(max2, sub4); int max4 = Math.max(max3, sub5); int max5 = Math.max(max4, sub6); int max6 = Math.max(max5, sub7); int max7 = Math.max(max6, sub8); int max8 = Math.max(max7, sub9); int max9 = Math.max(max8, sub10); int max10 = Math.max(max9, sub11); int max11 = Math.max(max10, sub12); int max12 = Math.max(max11, sub13); int max13 = Math.max(max12, sub14); System.out.println("Highest Marks = " + Math.max(max13, sub15)); // Average float avg = (float) total / 15; System.out.println("Average is " + avg); // Remarks if (percent <= 50) { System.out.println("Remarks: You need to work hard!"); } else if (percent >= 80 && percent <= 90) { System.out.println("Remarks: Good Marks :)"); } else if (percent >= 90) { System.out.println("Remarks: Excellent"); } else { System.out.println("Remarks: Good"); } } else { System.out.println("Values are Greator!"); } } else { System.out.println("Error: Number of subjects should not be more than 15 or not less than 0"); } // System.out.println("Enter the marks of 2 subjects (out of 100)"); // System.out.println("Enter the marks of subject 1:"); // int sub1 = sc.nextInt(); // System.out.println("Enter the marks of subject 2:"); // int sub2 = sc.nextInt(); // if (sub1 <= 100 && sub2 <= 100) { // // Total // int total = sub1 + sub2; // System.out.println("Total = " + total); // // Percentage // float percent = (float) total / 200 * 100; // System.out.println("Percentage = " + percent); // // Highest Marks // if (sub1 > sub2) { // System.out.println("Highest marks scored is " + sub1); // } else { // System.out.println("Highest marks scored is " + sub2); // } // // Average // float avg = (float) total / 2; // System.out.println("Average is " + avg); // // Remarks // if (percent <= 50) { // System.out.println("Remarks: You need to work hard!"); // } else if (percent >= 80 && percent <= 90) { // System.out.println("Remarks: Good Marks :)"); // } else if (percent >= 90) { // System.out.println("Remarks: Excellent"); // } else { // System.out.println("Remarks: Good"); // } // } else { // System.out.println("Values are Greator!"); // } } } } 15 Subjects Output Check out how the program works: https://www.blogger.com/video.g?token=AD6v5dwD6iubllHqPoMQMVMCJtvqvDPdP4lcZ3e2JgDQ119CmmdCcjAxnh2c2X7eupES6oxT__UDFgdPpT0Xft8eg6HoSEsj7lRq3GhGATBd1LMngjWySz0BC2ilV3klgxxSC3_q8wL6 Thanks for reading! Check out my , I keep posting random stuff here 😉. website