answer.
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
Genrish500 [490]
1 year ago
13

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

d be asked if he or she wishes to per- form the operation again. If so, the loop should repeat; otherwise it should terminate.
Computers and Technology
1 answer:
iVinArrow [24]1 year ago
5 0

The do-while loop for the given problem is shown below.  

do  

{  

  // user asked to enter two numbers  

  cout<<"Enter two numbers to be added."<<endl;  

  cin>>num1;  

  cin>>num2;  

  sum = num1 + num2;  

 

  // sum of the numbers is displayed  

  cout<<"Sum of the two numbers is "<<sum<<endl;  

  // user asked whether to perform the operation again  

  cout<<"Do you wish to continue (y/n) ?"<<endl;  

   cin>>choice;  

}while(choice != 'n');  

The variables to hold the two numbers and their sum are declared as float so that the program should work well for both integers and floating numbers.

float num1, num2, sum;

The char variable is taken since it holds only a single-character input from the user, 'y' or 'n'.

char choice;

The whole program is given below.

#include <iostream>

using namespace std;

int main() {

float num1, num2, sum;

char choice;  

do  

{  

  // user asked to enter two numbers  

  cout<<"Enter two numbers to be added."<<endl;  

  cin>>num1;  

  cin>>num2;  

  sum = num1 + num2;  

  // sum of the numbers is displayed  

  cout<<"Sum of the two numbers is "<<sum<<endl;  

  // user asked whether to perform the operation again  

  cout<<"Do you wish to continue (y/n) ?"<<endl;  

  cin>>choice;  

}while(choice != 'n');

cout<<"Quitting..."<<endl;

}

You might be interested in
Sharon is thinking about opening a bakery. She knows she wants to set her own hours, reduce her stress and make a profit. But sh
hodyreva [135]
Please provide complete details.
4 0
1 year ago
Why is project scope management so challenging in IT projects? What suggestions do you have for preventing scope creep in projec
seropon [69]

Answer:

Explanation:

<u>Ways to Avoid Scope Creep</u>

Scope creep is what happens when changes are made to the scope of a project without any control. Changes happen to projects all the time without been notify ontime as a project manager. It is that very rare project that ends up delivering exactly what was asked for on the first day. However, without there being some control over the changes, a project manager has little chance of keeping on top of the work and managing the project effectively.

Generally, scope creep is when new requirements are added after the project has commence. These changes are not properly reviewed. The project team is expected to deliver them with the same resources and in the same time as the original scope.

On the other hand, as a project manager you could end up with a project with lots of approved, considered changes, that never ends because every time you think you have finished a new requirement arrives in your inbox and you have to make more changes.

The following are five ways to keep control of your project.

<em>1-Document the Requirements</em>

<em>2-Set up Change Control Processes</em>

<em>3-Create a Clear Project Schedule</em>

<em>4-Verify the Scope with the Stakeholders</em>

<em>5-Engage the Project Team</em>

6 0
1 year ago
5.15 LAB: Output values below an amount Write a program that first gets a list of integers from input. The input begins with an
IgorC [24]

Answer:

# the terminal display waiting for the user to enter the input

# the received input is assigned to user_input

user_input = input()

# the user_input is splitted based on space and is assigned to integerlist

integerlist = user_input.split(" ")

# the last element in the integerlist is assigned as threshold

threshold = int(integerlist[len(integerlist) - 1])

# a for loop that loop from index 1 to second to the last element in the list

# the loop compare each element with the threshold

# if element is less than threshold, it is displayed

# the loop start from index 1 because index 0 represent number of element

for i in range(1, (len(integerlist) - 1)):

       if int(integerlist[i]) < threshold:

           print(integerlist[i], sep="")

Explanation:

The program is written in Python and well commented.

An sample of program output when it is executed is attached.

5 0
2 years ago
Read 2 more answers
What technology gets its name from the notion that it ignores the traditional A, B, and C class designations for IP addresses?
goblinko [34]

Answer:

Classless Inter-Domain Routing

Explanation:

Classless Inter-Domain Routing (CIDR), pronounced “cider” or “sidder,” gets its name from the notion that it ignores the traditional A, B, and C class designations for IPv4 addresses and sets the network-host ID boundary wherever it wants to, in a way that simplifies routing across the resulting IP address spaces.

3 0
1 year ago
Assume that a boolean variable workedOvertime has been declared, and that another variable, hoursWorked has been declared and in
meriva

Answer:

The c++ program to show the use of Boolean variable is given below.

#include <iostream>

using namespace std;  

int main() {    

  int hoursWorked = 44;

   bool workedOvertime;        

   cout<<"This program shows the use of boolean variable." <<endl;    

   // overtime refers to working hours more than 40 hours

   if(hoursWorked > 40)

   {

       workedOvertime = true;

       cout<<"The value of boolean variable workedOvertime is true or "<<workedOvertime<<endl;

   }

   // if working hours are less than or equal to 40, overtime is not considered        

   else

   {

       workedOvertime = false;

       cout<<"The value of boolean variable workedOvertime is false or "<<workedOvertime<<endl;

   }

   return 0;

}  

OUTPUT

This program shows the use of boolean variable.

The value of boolean variable workedOvertime is true or 1  

Explanation:

This program uses a boolean variable to indicate the overtime of working hours.

The boolean variable is declared as shown.

bool workedOvertime;  

The working hours is stored in an integer variable which is declared and initialized within the program itself.

int hoursWorked = 44;

Depending on the value of working hours, the boolean variable is assigned the value true or false.  

if(hoursWorked > 40)

   {

       workedOvertime = true;

       cout<<"The value of boolean variable workedOvertime is true or "<<workedOvertime<<endl;

   }

else

   {

       workedOvertime = false;

       cout<<"The value of boolean variable workedOvertime is false or "<<workedOvertime<<endl;

   }

The value of boolean variable is displayed to the user.

In the above program, the working hours are 44 which is more than normal working hours of 40. Hence, boolean variable is assigned value true.

This program does not accept user input for working hours as stated in the question. Since value of working hours is not accepted from the user, there is no logic implemented to check the validity of the input.

This program can be tested for different values of working hours to test for the boolean variable.

8 0
1 year ago
Other questions:
  • In object oriented programming, what is another name for the "attributes" of an object?
    14·1 answer
  • Which port, along with a special card and cables, supports the connection of microcomputers, modems, and printers in a local are
    6·1 answer
  • Which one of the following is the best example of an authorization control? (a)- Biometric device (b)- Digital certificate (c)-A
    11·1 answer
  • You work for a shipping company and your manager receives orders from various customers everyday some existing ,some new .your m
    6·1 answer
  • Write a class with a constructor that accepts a String object as its argument. The class should have a method that returns the n
    13·1 answer
  • Question 1 :Which type of unshielded twisted pair (UTP) cable is commonly used for 1000BASE-T Ethernet networks and is often mad
    8·1 answer
  • Write a function that implements another stack function, peek. Peek returns the value of the first element on the stack without
    11·1 answer
  • 2 Name the package that contains scanner class?​
    10·1 answer
  • Create a different version of the program that: Takes a 3-digit number and generates a 6-digit number with the 3-digit number re
    14·1 answer
  • George is working with an image in Photoshop. He added a lot of effects to the image. He saved the first draft of the file. The
    6·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!