-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAddcalc.java
More file actions
31 lines (29 loc) · 1.09 KB
/
Addcalc.java
File metadata and controls
31 lines (29 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package nyc.c4q.disonruan;
/**
* Created by fattyduck on 3/5/15.
*/
import java.util.Scanner;
//import scanner
public class Addcalc {
public static void main(String[] args){
double first, second, third, sum, average;
Scanner cow=new Scanner(System.in);
//initialized scanner
System.out.println("what is the first number?");
first=cow.nextDouble();
System.out.println("your first number is " + first);
System.out.println("what is the second number?");
second=cow.nextDouble();
System.out.println("your second number is " + second);
System.out.println("what is the third number");
third=cow.nextDouble();
System.out.println("your third number is " + third);
sum=first+second+third;
System.out.print("the sum of your three numbers is (" + first+" ) + (" + second+") + (" +third +") =");
System.out.printf("%.4f", sum);
//limited decimals to 4 places (0.0000)
average = sum / 3;
System.out.print("\n the average is ");
System.out.printf("%.4f", average);
}
}