subject

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;

}

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 10:00
How do i delete my account on this because i didn't read this agreements and also i put age at xd
Answers: 1
question
Computers and Technology, 23.06.2019 13:30
Me ! evelyn is a manager in a retail unit. she wants to prepare a report on the projected profit for the next year. which function can she use? a. pmt b. round c. division d. what-if analysis
Answers: 2
question
Computers and Technology, 24.06.2019 08:10
Where are american poets found in the dewey decimal system
Answers: 1
question
Computers and Technology, 24.06.2019 10:00
Each time you save a document, you will need to type in the file type in which it should be saved you can select the save button to save it with the same file name if it has been previously saved you will need to select the location to save the file you will need to use the save as dialog box
Answers: 1
You know the right answer?
Accumulating Totals in a Loop

Summary

In this lab, you add a loop and the...
Questions
Questions on the website: 13722367