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 does the following code print? time_of_day = ["morning", "afternoon", "evening"] for word in time_of_day: print "Good " + w
jek_recluse [69]

Answer:

syntaxerror

Explanation:

the print is missing a parenthesis - it will give the error:

SyntaxError: Missing parentheses in call to 'print'.

if you did put parenthesis it would say

Good morning

Good afternoon

Good evening

8 0
2 years ago
_______ data updates in your destination document if there are changes to the source data.
Lynna [10]
Linked or integrated
5 0
3 years ago
Namedroppers is a tool that can be used to capture Web server information and vulnerabilities in a Web site's pages that could a
Alexxx [7]

Answer:

False

Explanation:

Namedroppers help you look for domain names that are constantly updated on a daily basis. You can purchase a domain name of your choice from the results of the available domain names that are populated by namedropper. The description from the question above belongs to web application vulnerability scanners. These scanners are automated to scan web apps and look for vulnerabilities that most attackers take advantage of like SQL injection and buffer overflows.

8 0
4 years ago
What is the meaning of the term plot?<br>A. the final outcome of the story​
Amanda [17]

Answer:

The meaning of the term plot is the plan, scheme, or main story of a literary or dramatic work, as a play, novel, or short story.

Explanation:

5 0
3 years ago
Design a program takes as input, X, an unsorted list of numbers, and returns the sorted list of numbers in X. The program must b
Lelechka [254]

Answer:

The program in python is as follows:

def split(X):

   L = []; G = []

   for i in range(len(X)):

       if X[i]>=X[0]:

           G.append(X[i])

       else:

           L.append(X[i])

   L.sort(); G.sort()

   return L,G

X = []

n = int(input("Length of X: "))

for i in range(n):

   inp = int(input(": "))

   X.append(inp)

   

if len(X) == 0 or len(X) == 1:

   print(X)

else:

   X1,X2=split(X)

   newList = sorted(X1 + X2)

   print(newList)

Explanation:

The following represents the split function in the previous problem

def split(X):

This initializes L and G to empty lists

   L = []; G = []

This iterates through X

   for i in range(len(X)):

All elements of X greater than 0 equal to the first element are appended to G

      <em> if X[i]>=X[0]:</em>

<em>            G.append(X[i])</em>

Others are appended to L

<em>        else:</em>

<em>            L.append(X[i])</em>

This sorts L and G

   L.sort(); G.sort()

This returns sorted lists L and G

   return L,G

The main function begins here

This initializes X

X = []

This gets the length of list X

n = int(input("Length of X: "))

This gets input for list X

<em>for i in range(n):</em>

<em>    inp = int(input(": "))</em>

<em>    X.append(inp)</em>

This prints X is X is empty of has 1 element

<em>if len(X) == 0 or len(X) == 1:</em>

<em>    print(X)</em>

If otherwise

else:

This calls the split function to split X into 2

   X1,X2=split(X)

This merges the two lists returned (sorted)

   newList = sorted(X1 + X2)

This prints the new list

   print(newList)

7 0
3 years ago
Other questions:
  • Operating systems that have windows and icons have which type of user interface?
    15·1 answer
  • The syntax used for referencing cells with their worksheet names is the sheet name, followed by ____, then the usual column lett
    8·1 answer
  • What are some good invention names for an air filter?
    14·1 answer
  • A posting error is:
    8·1 answer
  • Study the sentences below. A.Changing the properties of characters in a sentence or paragraph in a Word document helps increase
    5·2 answers
  • Files and folders in UNIX can be removed using the
    8·1 answer
  • A rookie programmer has just typed over 1000 lines code into the command line interpreter for a project that is due the next day
    8·1 answer
  • State two ways of preventing virus attack on a computer.​
    12·1 answer
  • Internet speed test, why does it take some time to get maximum speed
    14·1 answer
  • I still need help, thank you! Will give Brainliest ​
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!