-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSumar.java
More file actions
26 lines (23 loc) · 1.03 KB
/
Copy pathSumar.java
File metadata and controls
26 lines (23 loc) · 1.03 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
//Excercise
//Write a do-while loop that asks the user to enter two numbers. The numbers should be added and the sum displayed.
//The loop should ask the user whether he or she wishes to perform the operation again. If so, the loop should repeat;
//otherwise it should terminate.
import java.util.Scanner;
public class Sumar {
public static void main (String[] args){
int respuesta = 0;
do {
Scanner lector = new Scanner(System.in);
System.out.println("Ingrese el primer numero: ");
int numOne = lector.nextInt();
System.out.println("Ingrese el segundo numero: ");
int numTwo = lector.nextInt();
int Sum_ar = numOne + numTwo;
System.out.println("La suma de " + numOne + " + " + numTwo + " = " + Sum_ar );
System.out.println("Desea hacer otra suma? ( si = 1 /no = 0 ) ");
respuesta = lector.nextInt();
}
while( respuesta == 1);
System.out.println("Termine de sumar.");
}
}