# Lab3_2 - d //keeps a count of scores to find numbers of...

This preview shows page 1. Sign up to view the full content.

/**Trinity Martin *Week 03 *Lab 3.2 *IT 218 *This program reads an unspecified number of scores from an input dialog box and determines scores above or equal to the average. */ * import javax.swing.JOptionPane; i public class Lab3_2 { // Main method public static void main(String[] args) { double[] scores = new double[100]; double sum = 0; int count = 0; i do { String scoreString = JOptionPane.showInputDialog(null, "Enter a new score"); //prompts user to enter score scores[count] = Double.parseDouble(scoreString); sum += scores[count]; } while (scores[count++] >= 0); //loop for score counting } double average = (sum - scores[count]) / (count - 1);
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: d //keeps a count of scores to find numbers of below and above average int numOfAbove = 0; int numOfBelow = 0; for (int i = 0; i < count - 1; i++) if (scores[i] >= average) numOfAbove++; //counter for number above average else numOfBelow++; //counter for number below average n System.out.println("Average is " + average); //displays desired information to user System.out.println("Number of scores above or equal to the average " + numOfAbove); System.out.println("Number of scores below the average " + numOfBelow); + System.exit(0); //exits the program } }...
View Full Document

## This note was uploaded on 07/26/2011 for the course IT 218 taught by Professor Accampo,e during the Spring '11 term at ITT Tech Pittsburgh.

Ask a homework question - tutors are online