java program calculates the total marks, average mark, highest mark, lowest mark
- برمجة جافا
- 2022-04-08
- softwareEngineer
الأجوبة
import java.util.Scanner;
public class Main
{
public static void main(String[] args) {
Scanner input= new Scanner(System.in);
System.out.println("welcome, enter the number of subjects:");
int subjects_number= input.nextInt();
double marks[]=new double[subjects_number];
double totalMarks=0;
double highestMark=-1,lowestMark=101;
for(int i=0;i<subjects_number;i++)
{
System.out.println("enter mark");
marks[i]= input.nextDouble();
totalMarks=totalMarks+marks[i];
if(marks[i]>highestMark)
highestMark=marks[i];
if(marks[i]<lowestMark)
lowestMark=marks[i];
}
System.out.println("total marks is "+totalMarks);
System.out.println("average of marks is "+(totalMarks/subjects_number));
System.out.println("highest mark is "+highestMark);
System.out.println("lowest mark is "+lowestMark);
}
}
أسئلة مشابهة
القوائم الدراسية التي ينتمي لها السؤال