For your homework today, write a program that calculates and prints out the average of three numbers. It should declare and initialize four double variables, one for each number and one for the average. Challenge: use a Scanner to read in the three numbers from the user. (You do not have to use any functions to solve this homework assignment.)
Search
kevinzhao183
Oct 18, 2020
Intro to Java 10/17/20 Homework
Intro to Java 10/17/20 Homework
0
import java.util.Scanner; class Main { public static void main(String[] args) { System.out.println("type three numbers for their average"); Scanner x = new Scanner(System.in); Scanner y = new Scanner(System.in); Scanner z = new Scanner(System.in); double a = x.nextDouble(); double b = y.nextDouble(); double c = z.nextDouble(); double d = ((a+b+c)/3); System.out.println(d); } }
class Main { public static void main(String[] args) { double a = 4; double b = 8; double c = 12; double average = (a + b + c) / 9; System.out.println(average); } }
import java.util.Scanner; class Main { public static void main(String[] args) { System.out.println("Hey! Write down 3 numbers that you want the average of:)"); Scanner a = new Scanner(System.in); Scanner b = new Scanner(System.in); Scanner c = new Scanner(System.in); double a = a.nextDouble(); double b = b.nextDouble(); double c = c.nextDouble(); double x = ((a + b + c)/3); System.out.println(x); } }