Homework 3: Muni ridership calculator

Objective: To perform a simple calculation based on user input

Write a program that asks the user for survey data about Muni riders, and outputs a summary of that data. Your program should first ask the user which Muni line was surveyed. Then the program asks the user how many days the survey was conducted, storing an integer answer, and then enter the number of riders that were counted (also an int). Your program divides the number of riders by the number of days and outputs the resulting average daily ridership. If that average is not a whole number, make sure you show the decimal value (such as in the examples below). You should use a typecast to make this work. Please use "printf" to display the result with 2 digits after the decimal point (rounded to the nearest hundredth).

Your program should behave like shown below (remember that "[cpersiko@fog cs111a]$" is the Linux prompt; your program does not output this)

Sample Input/Output on Linux:

[cpersiko@fog cs111a]$ java HW3
Welcome to the Muni Ridership Calculator.
Which Muni line did you survey?  K-Ingleside
How many days did you survey ridership?  5
How many riders did you count?  123456
According to your survey, an average of 24,691.20 people
rode the K-Ingleside per day.
[cpersiko@fog cs111a]$ java HW3
Welcome to the Muni Ridership Calculator.
Which Muni line did you survey?  N-Judah
How many days did you survey ridership?  30
How many riders did you count?  25000                  
According to your survey, an average of 833.33 people
rode the N-Judah per day.
[cpersiko@fog cs111a]$ 

Rules

Return to main CS 111A page