Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

How to print out which students have a score of 5 or less. Output the student number of each student who earned a score of

How to print out which students have a score of 5 or less. Output the student number of each student who earned a score of 5 or less. Java code. Thank you in advance!

Should output: "The following students have at least one scoore <= 5

1

3

4

5

8

9

11

12 "

my code so far: package com.company; import java.util.*; import java.lang.*; import java.io.*; public class Main { static final int STUDENTS = 12; static final int SCORES = 10; public static void main(String[] args) throws FileNotFoundException { File file = new File("input.txt"); Scanner stdin = new Scanner(file); int[][] quizScores = new int[STUDENTS][SCORES]; for (int student = 0; student < STUDENTS; ++student) { for (int score = 0; score < SCORES; ++score) { quizScores[student][score] = stdin.nextInt(); } } //Prints out scores double avgScores[] = new double[STUDENTS]; System.out.println("The scores are:"); for (int students = 0; students < STUDENTS; ++students) { for (int scores = 0; scores < SCORES; ++scores) { System.out.print(quizScores[students][scores] + " "); } System.out.println(); } //calculates avg for each student for (int students = 0; students < STUDENTS; ++students) { double total = 0; double avg = 0; for (int scores = 0; scores < SCORES; ++scores) { total = total + quizScores[students][scores]; } avg = total / SCORES; avgScores[students] = avg; } System.out.println(); double highestAvgScore = avgScores[0]; int highestAvgScoreStudentNumber = 0; for (int students = 0; students < STUDENTS; ++students) { if (avgScores[students] > highestAvgScore) { highestAvgScore = avgScores[students]; highestAvgScoreStudentNumber = students; } } System.out.println("The highest average score was earned by student " + (highestAvgScoreStudentNumber)); } } 

input file:

9 8 7 6 7 8 9 8 7 6 8 7 6 5 4 3 5 6 7 8 9 8 7 8 9 9 9 9 9 9 1 2 3 4 5 6 7 7 8 9 2 3 3 5 6 7 7 8 9 9 9 9 9 9 9 9 9 9 9 9 10 10 10 10 10 10 10 9 9 9 7 6 6 6 6 6 6 6 6 4 2 3 5 6 7 8 7 7 6 5 8 9 8 7 6 6 8 9 9 10 3 3 3 8 6 4 5 7 9 2 1 1 1 1 3 2 5 5 2 3 

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Programming With Visual Basic .NET

Authors: Carsten Thomsen

2nd Edition

1590590325, 978-1590590324

More Books

Students also viewed these Databases questions

Question

What advice would you provide to Jennifer?

Answered: 1 week ago

Question

What are the issues of concern for each of the affected parties?

Answered: 1 week ago