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 Java 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 file named LeftOrRight. java is open.

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 and using the data listed above and verify that the output is correct.

// LeftOrRight. java - 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.

import java. util. Scanner;

public class LeftOrRight

{

public static void main(String args[])

{

Scanner s = new Scanner(System. in);

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() method

System. out. println("Enter L if you are left-handed, R if you are right-handed or X to quit.");

leftOrRight = s. nextLine();

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

// Write your loop here.

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

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

System. out. println("Number of left-handed students: " + leftTotal);

System. out. println("Number of right-handed students: " + rightTotal);

System. exit(0);

} // End of main() method.

} // End of LeftOrRight class.

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 01:50
A.) generate scaffolding to create database for your application. develop all the entities identified in assignment #2. add any additional that may be identified later. b.) add data validation rules to the models that are appropriate for your application and data. c.) create links for each scaffold in the header section. part 2: application updates [30 points] a.) add two additional views to the "home" controller you created in assignment #1. b.) the two views should be named as “privacy" and "". c.) link the two newly created views in the footer section. hint: you would need to modify the “home" controller definition and create “privacy.html.erb" and “.html.erb" files in appropriate locations.
Answers: 3
question
Computers and Technology, 23.06.2019 07:30
Which option allows you to view slides on the full computer screen?
Answers: 1
question
Computers and Technology, 23.06.2019 15:30
Hey so i was just trying out some game hacks so i took a paste from online and built it in my visual studio and then suddenly my computer was working or clicking on stuff on its own am i hacked?
Answers: 1
question
Computers and Technology, 23.06.2019 21:10
Asample of 200 rom computer chips was selected on each of 30 consecutive days, and the number of nonconforming chips on each day was as follows: 8, 19, 27, 17, 38, 18, 4, 27, 9, 22, 30, 17, 14, 23, 15, 14, 12, 20, 13, 18, 14, 20, 9, 27, 30, 13, 10, 19, 12, 26. construct a p chart and examine it for any out-of-control points. (round your answers to four decimal places.)
Answers: 2
You know the right answer?
Accumulating Totals in a Loop

Summary

In this lab, you add a loop and the...
Questions
question
History, 06.07.2019 08:10
question
Mathematics, 06.07.2019 08:10
question
Mathematics, 06.07.2019 08:10
Questions on the website: 13722367