Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Java Programming I need help writing a program that does the following for it\'s

ID: 3879445 • Letter: J

Question

Java Programming

I need help writing a program that does the following for it's input and output as show in the example below:

Here is what the program needs to do (It's also reading in as a Scanner input = new Scanner(System.in);):

Here are the Instructions:

The input contains n lines for O

Explanation / Answer

package psolve; import java.util.*; public class Score { public static void main(String[] args) { Scanner sc = new Scanner(System.in); Map teamTime = new HashMap(); Set solvedProblems = new HashSet(); int totalTime = 0; while (sc.hasNextLine()) { String input = sc.nextLine(); if (input.equals("-1")) { break; } String[] inputs = input.split(" "); int time = Integer.parseInt(inputs[0]); String problem = inputs[1]; String status = inputs[2]; if (status.equals("wrong")) { teamTime.merge(problem, 20, (a, b) -> a + b); } else { solvedProblems.add(problem); teamTime.merge(problem, time, (a, b) -> a + b); } } for (String problem : solvedProblems) { totalTime += teamTime.get(problem); } System.out.println(solvedProblems.size() + " " + totalTime); } }
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote