-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDoWhile.java
More file actions
30 lines (27 loc) · 840 Bytes
/
DoWhile.java
File metadata and controls
30 lines (27 loc) · 840 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
package Practice.Assignments;
import java.util.*;
import java.lang.*;
public class DoWhile {
public static void main(String[] args) {
Scanner number = new Scanner(System.in);
int count = 1;
do {
System.out.print("Enter the first number: ");
int number1 = number.nextInt();
System.out.print("Enter the second number: ");
int number2 = number.nextInt();
int sum = number1 + number2;
System.out.println("sum = " + sum);
System.out.print("Enter '0' to continue or any number to exit: ");
int exit = number.nextInt();
if (exit != 0) {
break;
}
else {
continue;
}
}
while (count > 0);
System.out.println();
}
}