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
Similarities between incremental and<br> prototyping models of SDLC
Ahat [919]

Prototype Model is a software development life cycle model which is used when the client is not known completely about how the end outcome should be and its requirements.

Incremental Model is a model of software consequence where the product is, analyzed, developed, implemented and tested incrementally until the development is finished.

<h3>What is incremental model in SDLC?</h3>

The incremental Model is a process of software development where conditions are divided into multiple standalone modules of the software development cycle. In this model, each module goes through the conditions, design, implementation and testing phases.

The spiral model is equivalent to the incremental model, with more emphasis placed on risk analysis. The spiral model has four stages: Planning, Risk Analysis, Engineering, and Evaluation. A software project frequently passes through these phases in iterations

To learn more about Prototype Model , refer

brainly.com/question/7509258

#SPJ9

5 0
1 year ago
Your boss asks you to transmit a small file that includes sensitive personnel data to a server on the network. the server is run
polet [3.4K]
If an attacker can see transmitted packets, they will be able to see login credentials and be able to log in to the server. Additionally, the sensitive data in the file will be visible to the attacker. A better way would be to transfer the file using sftp or tftp.
4 0
3 years ago
How does a author develop a character in a story?
Eva8 [605]
Sometimes they base them off their selves or others they know
3 0
4 years ago
Read 2 more answers
Inputs to a system that can enhance performance is called
disa [49]
Inputs to a system that can enhance performance is called Resources
6 0
3 years ago
Read 2 more answers
Define the missing method. licenseNum is created as: (100000 * customID) licenseYear, where customID is a method parameter. Samp
g100num [7]

Answer:

I am writing the program in JAVA and C++

JAVA:

public int createLicenseNum(int customID){  //class that takes the customID as parameter and creates and returns the licenseNum

       licenseNum = (100000 * customID) + licenseYear;  //licenseNum creation formula

       return(licenseNum);     }

In C++ :

void DogLicense::CreateLicenseNum(int customID){ //class that takes the customID as parameter and creates the licenseNum

licenseNum = (100000 * customID) + licenseYear; } //licenseNum creation formula

Explanation:

createLicenseNum method takes customID as its parameter. The formula inside the function is:

licenseNum = (100000 * customID) + licenseYear;

This multiplies 100000 to the customID and adds the result to the licenseYear and assigns the result of this whole expression to licenseNum.

For example if the SetYear(2014) means the value of licenseYear is set to 2014 and CreateLicenseNum(777) this statement calls createLicenseNum method by passing 777 value as customID to this function. So this means licenseYear = 2014 and customID  = 777

When the CreateLicenseNum function is invoked it computes and returns the value of licenseNum as:

licenseNum = (100000 * customID) + licenseYear;

                     = (100000 * 777) + 2014

                     = 77700000 + 2014

licenseNum = 77702014                                                                                                        

So the output is:

Dog license: 77702014          

To call this function in JAVA:

public class CallDogLicense {

public static void main(String[] args) {//start of main() function

    DogLicense dog1 = new DogLicense();//create instance of Dog class

dog1.setYear(2014); // calls setYear passing 2014

dog1.createLicenseNum(777);// calls createLicenseNum passing 777 as customID value

System.out.println("Dog license: " + dog1.getLicenseNum()); //calls getLicenseNum to get the computed licenceNum value

return; } }

Both the programs along with the output are attached as a screenshot.

3 0
4 years ago
Read 2 more answers
Other questions:
  • A desktop _______ produces creative digital designs with illustration software.
    12·1 answer
  • A spreadsheet has some values entered: Cell A1 contains 10, cell A2 contains 14, cell A3 contains 7. You enter in cell A4 the fo
    6·1 answer
  • A data mart differs from a data warehouse in that: Group of answer choices it deals with a particular component or functional ar
    13·1 answer
  • What is wrong with this line of python code
    9·1 answer
  • The Python MySQL Connector library:
    15·1 answer
  • Grading on the curve is a method of grading that is based on the belief that letter grades for any given class should be distrib
    8·1 answer
  • What is the Piston Displacement having 3-inch bore and 3-inch stroke?
    11·1 answer
  • Spoderman memes<br> im scared-
    15·2 answers
  • Color.
    9·1 answer
  • Which best describes sorting, filtering, and deleting records?
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!