63 063
Assignments Done
99,1%
Successfully Done
In July 2018

Answer to Question #41345 in Java | JSP | JSF for solomon

Question #41345
accept marks of five students and then displays their average. The program shoud not accept mark which is less than 0 and mark greater than 100. use array concept.
Expert's answer
import java.util.Scanner;
 
public class Students {
 
public static void main(String[] args) {
  Scanner input = new Scanner(System.in);
  double[] arrayOfStudents = newdouble[5];
  double sum = 0;
  for (int i = 0; i <arrayOfStudents.length; i++) {
System.out.print("Input markfor " + (i + 1) + " student: ");
int mark =Integer.parseInt(input.nextLine());
if (mark >= 0 && mark<= 100) {
 arrayOfStudents[i] = mark;
sum += mark;
} else {
i--;
System.out.println("Badmark inputed. Try again");
}
  }
  double average = sum /arrayOfStudents.length;
  System.out.println("Average:" + average);
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions