Here is the problem:

Write an application that inputs three integers from the user and displays the sum, average, product, smallest, and largest of the numbers.Note: Calculation of average in this exercise should result in an integer representation of average without repeating decimals.

Here is my code:

Code :

//Exercise 2.17 from Deitel // Write an application that inputs three integers and displays sum, average, product, smallest, and largest of numbers //Average calculations should not have a repeating decimal import java.util.Scanner; //Java utilities package import statement public class Average { //main method for application public static void main (String [] args) { Scanner input = new Scanner(System.in); //Scanner input from user int number1, number2, number3, sum, average, product, smallest, largest; System.out.print( "Enter the first integer: " ); //prompt for number1 number1 = input.nextInt(); System.out.print( "Enter the second integer: " ); //prompt for number2 number2 = input.nextInt(); System.out.print( "Enter the third integer: " ); //prompt for number3 number3 = input.nextInt(); sum = number1 + number2 + number3; average = (number1 + number2 + number3) / 3; product = number1 * number2 * number3; System.out.printf( "Sum = %d \nAverage = %d \nProduct = %d \n", sum, average, product ); if (number1 < number2 && number1 < number3) //if number1 is smallest System.out.println( number1 + " is smallest"); if (number2 < number1 && number2 < number3) //if number 2 is smallest System.out.println( number2 + " is smallest"); if (number3 < number1 && number3 < number2) //if number3 is smallest System.out.println( number3 + " is smallest"); if (number1 > number2 && number1 > number3) //if number1 is largest System.out.println( number1 + " is largest"); if (number2 > number1 && number2 > number3) //if number 2 is largest System.out.println( number2 + " is largest"); if (number3 > number1 && number3 > number2) //if number3 is largest System.out.println( number3 + " is largest"); } //end main method } //end Average class

When I run the program with smaller numbers like 60, 30, 50 then the program runs fine. Once

I start entering 349284, 409823409, 123980128 as my integers then I get a negative product. I wish I could provide the cut off point for when I start seeing the negative product printed but I don't actually know. I tested 100,000 for all three integers and the product was negative again so I'm assuming anything greater than 100,000.

This maybe silly question :o but please let me know if I'm doing something wrong. Thanks!!

Also! I'm new please let me know if this question should be posted in a different section or on a different forum in general.