Answer to Question #275678 in Java | JSP | JSF for doeboy

Question #275678

Design a Java application that will allow a user to capture the top students for a module. Allow the


user to enter in the module name, followed by the number of students the user would like to


capture.


Continue to capture the results for the number of students entered. Once all the student results


have been captured create a results report.


In the results report display the student results entered, a student count and the average result


obtained.



1
Expert's answer
2021-12-04T20:47:29-0500
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        System.out.print("Module name: ");
        String moduleName = in.nextLine();
        System.out.print("Number of students: ");
        int numberOfStudents = in.nextInt();
        double[] results = new double[numberOfStudents];
        double total = 0;
        for (int i = 0; i < results.length; i++) {
            System.out.print("Student " + (i + 1) + ": ");
            results[i] = in.nextDouble();
            total += results[i];
        }
        System.out.println("\nREPORT");
        System.out.println(moduleName + "(Students: " + results.length + ")");
        for (int i = 0; i < results.length; i++) {
            System.out.println(results[i]);
        }
        System.out.printf("Average: %.2f\n", total / results.length);
    }
}

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 the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS