Question: In this lab, you add a loop and the statements that make up the loop body to a Java program provided. When completed, the program

In this lab, you add a loop and the statements that make up the loop body to a Java program 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 an L for left-handed or an R for right-handed.
import javax.swing.JOptionPane;
public class LeftOrRight
{
public static void main(String args[])
{
String leftOrRight =""; // L or R for one student.
int rightTotal =0; // Number of right-handed students.
int leftTotal =0; // Number of left-handed students.
leftOrRight = JOptionPane.showInputDialog("Enter L if you are left-handed, R if you are right-handed or X to quit.");
// Write your loop here.
// 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);
}
}// End of LeftOrRight class.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!