15.E ) Write a Java Program to display the grade of a student based on the following condition if marks greater than 80 the grade is “A+” otherwise grade is “A”.
Please answer it fast....
× No spam pls ×
Answers
Write a Java Program to display the grade of a student based on the following condition if marks greater than 80 the grade is “A+” otherwise grade is “A”.
***IN THE GIVEN PROGRAM U HAVE TO ENTER THE MARKS OF ALL SUBJECTS***
package com.tcc.java.programs;
import java.util.Scanner;
/**
* Java Program to print grade of a student
*/
public class StudentGrade {
public static void main(String[] args) {
int count, i;
float totalMarks = 0, percentage, average;
Scanner scanner;
scanner = new Scanner(System.in);
System.out.println("Enter Number of Subject");
count = scanner.nextInt();
System.out.println("Enter Marks of " + count + " Subject");
for (i = 0; i < count; i++) {
totalMarks += scanner.nextInt();
}
System.out.println("Total MArks : " + totalMarks);
// Each subject is of 100 Marks
percentage = (totalMarks / (count * 100)) * 100;
/* Printing grade of a student using switch case statement */
switch ((int) percentage / 10) {
case 9:
System.out.println("Grade : A+");
break;
case 8:
case 7:
System.out.println("Grade : A");
break;
case 6:
System.out.println("Grade : B");
break;
case 5:
System.out.println("Grade : C");
break;
default:
System.out.println("Grade : D");
break;
}
}
}
thanks ツツツ
@ConfusedPadhaku
Answer:
I have only coding of python