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

Three groups of visitors visit a museum each day: Adult, senior, and children. j

ID: 3744554 • Letter: T

Question

Three groups of visitors visit a museum each day: Adult, senior, and children.

java program that prompts the user to enter the number of visitors in each group, then calculates and prints the total number of the visitors and the percentage of each group.

Sample run:

   Enter the number of adult visitors: 55

Enter the number of senior visitors: 35

Enter the number of children visitors: 23

The visitor information:

****************************************

Adult: 55

Senior: 35

Children: 23

Total Number of Visitors: 113

Percentage of Adult Visitors: 48.67256637168141

Percentage of Senior Visitors: 30.973451327433626

Percentage of Children Visitors: 20.353982300884958

Explanation / Answer

import java.util.Scanner; public class Visitors { public static void main(String[] args) { Scanner in = new Scanner(System.in); System.out.print("Enter the number of adult visitors: "); int adults = in.nextInt(); System.out.print("Enter the number of senior visitors: "); int seniors = in.nextInt(); System.out.print("Enter the number of children visitors: "); int children = in.nextInt(); System.out.println("The visitor information:"); System.out.println("****************************************"); System.out.println("Adult: " + adults); System.out.println("Senior: " + seniors); System.out.println("Children: " + children); int total = adults + seniors + children; System.out.println("Total Number of Visitors: " + total); System.out.println("Percentage of Adult Visitors: " + (adults/(double)total*100.0)); System.out.println("Percentage of Senior Visitors: " + (seniors/(double)total*100.0)); System.out.println("Percentage of Children Visitors: " + (children/(double)total*100.0)); } }

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