Hello,
I am writing a program that will read in a pair of inputs, (P, S), summarizing the results of a code inspection. One input is the integer problem number, P, and the other is the severity level, S, of that problem. Since a typical code inspection will never have as much as 2000 problems, we should plan that 1≤ P ≤ 2000. Severity levels, S, may take on values of 1, 2, 3, 4, or 5, where 1 is the worst case. Use the situation where problem number equals zero, P = 0, as an indicator that there is no more problems to read in. When all problems are read in, the program should summarize the number of problems found in each severity category and print out that summary. As part of the summary, all the problem numbers, Ps, for the highest severity, Severity =1, should also be printed out.
This is what i have coded.
import java.util.*;
public class SummarizeResults
{
public static void main(String args[])
{
int p = -1;
int s = -1;
int[] Problem;
Problem = new int[2000];
Arrays.fill(Problem, 0);
/*for ( int i = 1; i < Problem.length; i++ )
{
System.out.println(Problem[ i ]);
}*/
int sev1 = 0;
int sev2 = 0;
int sev3 = 0;
int sev4 = 0;
int sev5 = 0;
/*while ( p !=0 && 1 <= p <= 2000)
{
//should i read in the pinut as a string and parse the information? I would need help doing this because i forgot how to.
Scanner input = new Scanner(System.in);
System.out.print("Enter problem number: ");
p = input.nextInt();
Scanner 2ndinput = new Scanner(System.in);
System.out.print("Now enter accompanying severity level: ");
s = 2ndinput.nextInt();
switch (s)
{
case 1 : sev1 = sev1 + 1;
Problem [i] = p;
i = i + 1;
break;
case 2 : sev2 = sev2 + 1;
break;
case 3 : sev3 = sev3 + 1;
break;
case 4 : sev4 = sev4 + 1;
break;
case 5 : sev5 = sev5 + 1;
break;
default: System.out.println ("something is wrong with the severity code for problem = ":, p )
}
Scanner input = new Scanner(System.in);
System.out.print("Enter problem number: ");
p = input.nextInt();
Scanner 2ndinput = new Scanner(System.in);
System.out.print("Now enter accompanying severity level: ");
s = 2ndinput.nextInt();
}
if ( 2000 < p || p < 0 )
{
System.out.print ( “Problem number = ” , p, “ is invalid and we are terminating with summary”)
}
else
{
System.out.print( “severity 1 =”, sev1, “severity 2 =”, sev2, “severity 3 =”, sev3, “severity 4 =”, sev4, “severity 5 =”, sev5)
System.out.print( “the following list contains all the severity 1 problem numbers.” )
for (int j = 1 ; j <= i ; j++ )
{
System.out.println ( “problem number =”, Problem [j] )
}
}*/
}
}
This is very rough and am getting a lot of errors. Can someone help me iron out the wrinkles plz?