Computers and Technology

Accumulating Totals in a Loop

Summary

In this lab, you add a loop and the statements that make up the loop body to a C++ program that is provided. When completed, the program should calculate two totals: the number of left-handed people and the number of right-handed people in your class. Your loop should execute until the user enters the character X instead of L for left-handed or R for right-handed.

The inputs for this program are as follows: R, R, R, L, L, L, R, L, R, R, L, X

Variables have been declared for you, and the input and output statements have been written.

Instructions

Ensure the source code file named LeftOrRight. cpp is open in the code editor.

Write a loop and a loop body that allows you to calculate a total of left-handed and right-handed people in your class.

Execute the program by clicking "Run Code" and using the data listed above and verify that the output is correct.

// LeftOrRight. cpp - This program calculates the total number of left-handed and right-handed

// students in a class.

// Input: L for left-handed; R for right handed; X to quit.

// Output: Prints the number of left-handed students and the number of right-handed students.

#include

#include

using namespace std;

int main()

{

string leftOrRight = ""; // L or R for one student.

int rightTotal = 0; // Number of right-handed students.

int leftTotal = 0; // Number of left-handed students.

// This is the work done in the housekeeping() function

cout << "Enter an L if you are left-handed, a R if you are right-handed or X to quit: ";

cin >> leftOrRight;

// This is the work done in the detailLoop() function

// Write your loop here.

// This is the work done in the endOfJob() function

// Output number of left or right-handed students.

cout << "Number of left-handed students: " << leftTotal << endl;

cout << "Number of right-handed students: " << rightTotal << endl;

return 0;

}

answer
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 10:30, dreyes439
You are almost finished updating a web site. as part of the update, you have converted all pages from html 4.0 to html5. the project is currently on schedule. however, your project manager has been asked by the marketing team manager to justify a day of time spent validating the site's html5 pages. the marketing team manager does not have technical knowledge of the internet or the web. which is the most appropriate explanation to provide to the marketing team manager?
Answers: 1
image
Computers and Technology, 23.06.2019 01:30, marmar72
Negative methods of behavior correction include all but this: sarcasm verbal abuse setting an example for proper behavior humiliation
Answers: 1
image
Computers and Technology, 23.06.2019 05:00, mikeysoulemison
Jason works as an accountant in a department store. he needs to keep a daily record of all the invoices issued by the store. which file naming convention would him the most?
Answers: 2
image
Computers and Technology, 23.06.2019 14:30, Vanesssajohn2962
Norder to receive financial aid at his vocational school, mario must fill out the fafsa. the fafsa is a form that must be completed to determine . in order to complete a fafsa, you must submit . the fafsa can students obtain
Answers: 2
Do you know the correct answer?
Accumulating Totals in a Loop

Summary

In this lab, you add a loop and the...

Questions in other subjects:

Konu
Biology, 16.11.2020 19:00
Konu
Mathematics, 16.11.2020 19:00
Konu
English, 16.11.2020 19:00