-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcalculate_1.java
More file actions
33 lines (33 loc) · 962 Bytes
/
calculate_1.java
File metadata and controls
33 lines (33 loc) · 962 Bytes
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
32
33
import java.util.*;
public class calculate_1{
public static void main(String args[]){
int n1, n2, n3, n4, n6,n7,n8;
double n5;
Scanner keyb;
String msg1, msg2, msg3, msg4,msg5,msg6;
keyb = new Scanner(System.in);//產生Scanner物件
System.out.println("Please type in an integer:");//printf()
n1 = keyb.nextInt();//scanf()
System.out.println("Hi, please type in another integer:");
n2 = keyb.nextInt();
System.out.println("Calculating!");
n3 = n1+n2;
n4 = n1-n2;
n5 = n1/n2;
n6 = n1%n2;
n7 = n1*n1;
n8 = n2*n2;
msg1="Integer1 + Integer2="+n3;
msg2="Integer1 - Integer2="+n4;
msg3="Integer1 / Integer2="+n5;
msg4="The remainder of Integer1 / Integer2="+n6;
msg5="Square of integer 1 is "+n7;
msg6="Square of integer 2 is "+n8;
System.out.println(msg1);
System.out.println(msg2);
System.out.println(msg3);
System.out.println(msg4);
System.out.println(msg5);
System.out.println(msg6);
}//main()
}//class