while Grades

while Grades - System.out.println"Please enter a new...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package grades; import java.util.*; /** * * @author Manny Duenas */ public class Grades { /** * @param args the command line arguments */ public static void main(String[] args) { // TODO code application logic here //Prepare for the loop String isContinue = "Yes"; double totalScore = 0; int count = 0; double currentScore = 0; Scanner in = new Scanner(System.in); //start the while loop while(isContinue.equalsIgnoreCase("Yes")) { //inside the loop
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: System.out.println("Please enter a new score"); if(in.hasNextDouble()) { currentScore = in.nextDouble(); } else { System.out.println("wrong input."); System.exit(0); } totalScore = totalScore + currentScore; //sum the scores count++; //update the control variable isContinue System.out.println("continue? (yes/no): "); isContinue = in.next(); }//This is the output //after the loop double average = totalScore / count; System.out.printf("the average score is: %.2f\n", average); } }...
View Full Document

{[ snackBarMessage ]}

Page1 / 2

while Grades - System.out.println"Please enter a new...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online