Q:

java program calculates the total marks, average mark, highest mark, lowest mark

0

write java program prompts student to enter number of subjects, then enter his marks of subjects, then calculates the total marks, average mark, highest mark, lowest mark.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

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);
}
}

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now