// Average.java // import Scanner class using java.util.Scanner import java.util.Scanner; public class Average { //prints average of three numbers public static void main (String[] args) { double num1, num2, num3; double average; // create Scanner object Scanner scan = new Scanner(System.in); // Three numbers as inputs are given by user. // To calculate average. num1 = scan.nextDouble(); num2 = scan.nextDouble(); num3 = scan.nextDouble(); // We know that average is equal to sum of all // numbers divided by total number. average = (num1 + num2 + num3)/3; // prints the average System.out.println(average); } }
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here