/* Author: Johnny A. Shaieb Program: Lab5 - lab5.java Date: 2-20-2002 4:30 Instructor: Gabriela Perez */ import java.text.NumberFormat; public class lab5 { public static void main(String[] args) { String flag = "Y"; int testscore = 0; int testmin = 0; int testmax = 0; int testcount = 0; int passed = 0; int flunked = 0; int sum = 0; NumberFormat formatter = NumberFormat.getNumberInstance(); formatter.setMaximumFractionDigits(2); formatter.setMinimumFractionDigits(2); ConsoleReader console = new ConsoleReader(System.in); System.out.print("Enter a Test Score: --OR-- Enter a Negative Number to QUIT "); testscore = console.readInt(); testmin = testscore; testmax = testscore; while(testscore >= 0) { if(testmin > testscore) { testmin = testscore; } if(testmax < testscore) { testmax = testscore; } if(testscore >= 60) { passed++; } else { flunked++; } //debug//System.out.println("MIN: " + testmin); //debug//System.out.println("MAX: " + testmax); testcount++; sum += testscore; System.out.print("Enter a Test Score: --OR-- Enter a Negative Number to QUIT "); testscore = console.readInt(); } double average = (double)sum/testcount; System.out.println("\n\n\n\n"); System.out.println("---------------------------------------"); System.out.println(" Test Score Summary"); System.out.println("---------------------------------------"); System.out.println("Test Scores Read In ==> " + testcount); System.out.println("Sum Of All the Test Scores ==> " + sum); System.out.println("Average (mean) ==> " + formatter.format(average)); System.out.println("Minimum Test Score ==> " + testmin); System.out.println("Maximum Test Score ==> " + testmax); System.out.println("How many passed ==> " + passed); System.out.println("How man flunked ==> " + flunked); } }