Class Work - intTwo = stdIn.nextInt();...

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

View Full Document Right Arrow Icon
/* Find the average of 3 integers, and display with 3 digists after the decimal point. * The integers will be input by the user. ******************/ import java.util.Scanner; public class Average { public static void main(String[] args) { Scanner stdIn = new Scanner(System.in); int intOne, intTwo, intThree; System.out.println("Please enter your first digit."); intOne = stdIn.nextInt(); System.out.println("Please enter your second digit.");
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: intTwo = stdIn.nextInt(); System.out.println("Please enter your third digit."); intThree = stdIn.nextInt(); System.out.println("The average is:"); double average; average = (intOne + intTwo + intThree); System.out.println(average / 3); } } /* initialize sum to 0 initialize cout to 0 while there is more input read number add number to sum add one to count avg is sum / count display avg...
View Full Document

This note was uploaded on 04/03/2010 for the course COMPSCI 600.107 taught by Professor Houlahan during the Spring '08 term at Johns Hopkins.

Ask a homework question - tutors are online