AverageOfThree - { int num1, num2, num3; double average;...

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

View Full Document Right Arrow Icon
//******************************************************************** // AverageOfThree.java Author: Lewis and Loftus // // Solution to Programming Project 2.2 //******************************************************************** / import java.util.Scanner; i class AverageOfThree { //----------------------------------------------------------------- // Reads three integers from the user and prints their average. //----------------------------------------------------------------- public static void main (String[] args)
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: { int num1, num2, num3; double average; Scanner sc = new Scanner (System.in); System.out.print ("Enter the first number: "); num1 = Integer.parseInt(sc.nextLine()); System.out.print ("Enter the second number: "); num2 = Integer.parseInt(sc.nextLine()); System.out.print ("Enter the third number: "); num3 = Integer.parseInt(sc.nextLine()); average = (double) (num1+num2+num3) / 3; System.out.println ("The average is: " + average); } }...
View Full Document

This note was uploaded on 05/17/2011 for the course COP 3530 taught by Professor Davis during the Spring '08 term at University of Florida.

Ask a homework question - tutors are online