1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
spin [16.1K]
3 years ago
5

Create a do-while loop that asks the user to enter two numbers. The numbers should be added and the sum displayed. The loop shou

ld ask the user whether he or she wishes to perform the operation again. If so, the loop should repeat; otherwise it should terminate
Sample Run1

Enter two numbers: 3 15

Do you want another operation: Yes

Enter two numbers: 45 56

Do you want another operation: No

Output1: Sum = 119

Sample Run2

Enter two numbers: 33 150

Do you want another operation: Yes

Enter two numbers: -56 56

Do you want another operation: Yes

Enter two numbers: 58 15

Do you want another operation: Yes

Enter two numbers: 123 87

Do you want another operation: No

Output2: Sum = 466
Computers and Technology
1 answer:
Gala2k [10]3 years ago
6 0

Answer:

import java.util.Scanner;

public class TestClock {

   public static void main(String[] args) {

       Scanner in = new Scanner(System.in);

       int sum = 0;

       char op;

       do{

           System.out.println("Enter two numbers");

           int num1= in.nextInt();

           int num2 = in.nextInt();

           sum = sum+num1+num2;

           System.out.println("Do you wish to perform another operation, Y/N");

           op =in.next().charAt(0);

       }while(op =='Y'||op=='y');

       System.out.println("sum "+sum);

   }

}

Explanation:

The code is implemented in Java progrmming language

  1. create an integer variable sum
  2. create a character variable op
  3. create a do while loop to request user to enter num1 and num2
  4. Request the user to also enter a char Y/N (yes or no repectively)
  5. While the char is Y keep adding up the sum and prompt the user to enter two new numbers
  6. Else break out of the loop and print the sum
You might be interested in
What did Adam and Eve look like?
Nata [24]
No one could possibly know, unfortunately.
6 0
3 years ago
Read 2 more answers
Preciso de ajudar para resolver esse exercício, é para amanhã cedo!!<br><br> Em Dev C++
LenKa [72]
Bbbbbbbbbbbbbbbbbbbbbb
3 0
2 years ago
Read 2 more answers
Write a Python program to convert temperatures to and from celsius, fahrenheit.
Rudiy27

Answer:

https://www.w3resource.com/python-exercises/python-conditional-exercise-2.php

3 0
2 years ago
Is the process of modifying something to make it fit certain criteria.
alexandr402 [8]

Answer:

Design Process

8 0
2 years ago
Select the correct line of missing code to create an output of "hello."
s2008m [1.1K]

Answer:

B

Explanation:

This feels like an error on the question issuer's part.

3 0
2 years ago
Other questions:
  • Describe encryption at gateways in thePresentation layer of the OSI Reference Model
    6·1 answer
  • This program has some errors in it that are needed to be checked import java.io.*;
    13·1 answer
  • When performing a basic search with Bing, you first type in your search expression and then click a button to begin the search;
    13·1 answer
  • What does social protocol means in network?
    9·1 answer
  • Jennifer works as a clerk in a company. The essential function of her job is typing on a keyboard. If she develops crippling art
    11·1 answer
  • Create and test a user-defined function named ufnFullName that combines the values of the two parameters named FirstName and Las
    15·1 answer
  • An IT suspects that an unauthorized device is connected to a wireless network. This is a result of pastry sharing on a device br
    13·1 answer
  • The welcome screen of the program 123D consists of ___
    15·1 answer
  • In PowerPoint, a picture might be a photograph, a shape you draw, a piece of clip art, or an illustration created using a graphi
    7·2 answers
  • Explain why computer professionals are engaged in technical services
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!