How I Built a Simple Report Card Program in Java for 15 Subjects Part 2
source link: https://hackernoon.com/how-i-built-a-simple-report-card-program-in-java-for-15-subjects-part-2
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
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!");
// }
}
}
}
Recommend
-
33
Learn how RxJS Subjects are used in real-world applications
-
9
A not so well known api in RxJava is the .hide() operator. When does one use the hide operator in Rx? From the docs:
-
8
C-Suite Lifestyle5 Subjects Buyers are Obsessed With Yet Businesses Keep Ignoring, Again and AgainMarcus SheridanWe see the...
-
3
Do You Need to Be Smart to Learn Certain Subjects 原文地址: https://www.scotthyoung.com/blog/2019/05/13/do-you-need-to-be-smar...
-
4
Tutorial How To Use RxJS Subjects, Behavior Subjects, and Replay Subjects JavaScript Intro...
-
4
Overview This course gives you easy access to the invaluable learning techniques used by experts in art, music, literature, math, science, sports, and many other disciplines. We’ll le...
-
2
How to capitalize on data without harming its subjects? Read later By
-
3
Short subjects: Realtime, Futexes, and ntfs3 This article brought to you by LWN subscribersSubscribers to LWN.net made this article — and everything that surrounds it — possible. If you...
-
1
ART | CREATIVITY | DESIGN | COLORS | HISTORYBeautiful Colors. Ugly Subjects.With a closing revelation about the existence of ugly colors“Assortment of Crayon Colors” Photograph by the AuthorIn...
-
3
@mayankvikashMayank VikashDeveloper and writer.NEWABOUT PAGE
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK