Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Average_Problem {
- public static void main(String[] args) {
- int value1 = 0, value2 = 0, value3 = 0, total = 0;
- double avg = 0.0;
- Scanner scan = new Scanner(System.in);
- System.out.print("Please enter the first integer: ");
- value1 = scan.nextInt();
- System.out.print("Please enter the second integer: ");
- value2 = scan.nextInt();
- System.out.print("Please enter the third integer: ");
- value3 = scan.nextInt();
- total = value1 + value2 + value3;
- avg = total / 3;
- System.out.println("The first integer you entered is " + value1 + ".");
- System.out.println("The second integer you entered is " + value2 + ".");
- System.out.println("The third integer you entered is " + value3 + ".");
- System.out.println("The average of the integers you entered is " + avg + ".");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement