Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package average_problem;
- import java.util.Scanner;
- public class Average {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- print("First int: ");
- int int1 = scanner.nextInt();
- print("Second int: ");
- int int2 = scanner.nextInt();
- print("Third int: ");
- int int3 = scanner.nextInt();
- double average = (int1 + int2 + int3) / 3.0;
- scanner.close();
- print("The average for the numbers " + int1 + ", " + int2 + ", and " + int3 + " is " + average);
- }
- public static void print(String something) {
- System.out.print(something);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement