Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create a program using a For loop or a While loop and a sentinel , that displays

ID: 3552176 • Letter: C

Question

Create a program using a For loop or a While loop and a sentinel, that displays the registration information for medical conferences. The price per person depends on the number of people a hospital registers. (For example, if a hospital registers 5 people then the amount owed by that hospital is $525). The following chart shows the charges per registrant:


Number of Registrants 1-4 Charge Per Person $125


Number of Registrants 5-11 Charge Per Person $105


Number of Registrants 12 or more Charge Per Person $80


The program should allow the user to enter the number registered for as many hospitals as desired. The program should display the total number of people registered, the total charge, and the average charge per registrant. (For example, if one company registers 5 people and a second company registers 2 people, then the total number of people registered is 7, the total charge is $775, and the average charge per registrant is $110.71).

Explanation / Answer

import java.util.*;
public class charge
{
public static void main(String[] args)
{
Scanner in =new Scanner(System.in);
int total_charge = 0;
int count = 0;
int number_of_Registrants = 1;
System.out.println("Enter number of Registrants (0 to stop) :");
number_of_Registrants = in.nextInt();
while(number_of_Registrants>0)
{
count = count + number_of_Registrants;
if(number_of_Registrants>=1 && number_of_Registrants<=4)
total_charge = total_charge + (number_of_Registrants*125);
else if(number_of_Registrants>=5 && number_of_Registrants<=11)
total_charge = total_charge + (number_of_Registrants*105);
else if(number_of_Registrants>=12)
total_charge = total_charge + (number_of_Registrants*80);
System.out.println("Enter number of Registrants (0 to stop) :");
number_of_Registrants = in.nextInt();
}
System.out.println("the total number of people registered is "+ count);
System.out.println("the total charge is $"+ total_charge);
System.out.printf("the average charge per registrant is $%.2f",(double)(total_charge)/count);
} // end main.
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote