Starting from:

$29.99

Assignment 2 Taxi Fare Estimator


COMP 248 
Assignment 2
Purpose: The purpose of this assignment is to help you learn Java
identifiers, assignments, input/output, selection and flow of
control statements: if, if/else and for loops
CEAB/CIPS ATTRIBUTES: Design/Problem analysis/Communication Skills
General Guidelines When Writing Programs:
Refer to assignment #1 handout.
Question 1: Taxi Fare Estimator
You are asked to develop a taxi fare estimator for a Montreal taxi company. Users who
are interested in receiving taxi service may use the estimator to get a quote for a ride.
The taxi company offers ride service in Greater Montreal Area. There are a few factors
that determine the taxi fare for a ride, i.e., car model, distance, whether or not the ride
time is within rush hours. There are two types of cars that may provide ride service:
base car models and limo car models. Depending on which rush hours the taxi service
is provided, the fare will increase accordingly. In short, the total fare equals to the fare
per km for each car model times ($/km) the estimated distance (km) times a rush hour
ratio (%).
- For base car model, the fare per km is $0.81;
- For limo car model, the fare per km is $1.55;
- If the ride is on any weekdays, there are three rush hour ratios that may apply:
o If between 8am and 10am or between 4pm and 5pm, the rush hour ratio
is 1.5;
o If between midnight (12am) and 6am, the rush hour ratio is 2;
o For the remaining time, the rush hour ratio is 1.
- If the ride is on weekend, there are two rush hour ratios that may apply:
o If between midnight (12am) and 6am, the rush hour ratio is 2;
o For the remaining time, the rush hour ratio is 1.3.
Below are two sample outputs to demonstrate the expected behavior of your program.
Note:
• User input is highlighted in green.
• Your program must display the same information but can be formatted
differently.
-------****-------****-------****-------****-----****-----
 Welcome to Montreal Taxi Fare Estimator!
-------****-------****-------****-------****-----****-----
Please select your taxi car model:
 1 – base car
 2 – limo car
Please enter the digit corresponding to your case:(1 or 2)
2
Please select which day you will be using the taxi service:
 1 - Weekday
 2 - Weekend
1
Please select the time you will be using the taxi service:
 1 - During 8am - 10am and 4pm - 5pm
 2 - From midnight 12am to 6am
 3 - None of the above
1
Please enter the estimated distance (km) of your ride:
34
Your estimated fare is $79.05000000000001
Thank you for using our service!
-------****-------****-------****-------****-----****-----
 Welcome to Montreal Taxi Fare Estimator!
-------****-------****-------****-------****-----****-----
Please select your taxi car model:
 1 – base car
 2 – limo car
Please enter the digit corresponding to your case:(1 or 2 )
1
Please select which day you will be using the taxi service:
 1 - Weekday
 2 - Weekend
2
Please select the time you will be using the taxi service:
 1 - Between midnight 12am and 6am
 2 - None of the above
2
Please enter the estimated distance (km) of your ride:
14
Your estimated fare is $14.742
Thank you for using our service!
Question 2: Reverse Input Number
You are asked to write a program that counts the number of digits of a number and
returns the reverse order of the digits in the number. The number with at most 10 digits
is provided by a user, e.g., for an input number of “12345”, the program would output
“5” and “54321” to the console. In addition, the program will ask whether the user
wants to continue to input another number or end this program.
Below is a sample output screen to illustrate the expected behavior of your program.
Your output does not need to be formatted in exactly the same way. Just make sure
the required information appears. Note: user input is highlighted in green.
Restriction: You are not to use variables of type String for this question. The number
entered by the user must be stored in a variable of type integer and be manipulated as
an integer.
Hint: You can use integer division and modulo to solve this problem (% and /).
What to submit:
Zip the 2 source codes (the .java files only please, not the entire project) of this
assignment as a .ZIP file (NOT .RAR) using the following naming convention:
a#_studentID, where # is the number of the assignment and studentID is
your student ID number.
For example, for this second assignment, student 123456 would submit a zip file
named a2_123456.zip
Submitting Assignment 2
Welcome to Our Reversing Number Program
------------------------------------------
Enter a number with at most 10 digits:
12345
Number of digits is 5
Reverse of 12345 is 54321
Do you want to try another number? (yes to repeat, no to stop)
yes
Enter a number with at most 10 digits:
1234567891
Number of digits is 10
Reverse of 1234567891 is 1987654321
Do you want to try another number? (yes to repeat, no to stop)
no
Thanks and have a great day!
How to submit:
For sections U & W, please check your Moodle course webpage and for section
EC please check your eConcordia webpage for instructions on how to submit
your assignment.
Evaluation Criteria for Assignment 2
Source Code
Comments for all 2 questions (3 pts.)
 Description of the program (authors, date, purpose) 1 pt.
 Description of variable and constants 1 pt.
 Description of the algorithm 1 pt.
Programming styles for all 2 questions (3 pts.)
 Use of significant names for identifiers 1 pt.
 Indentation and readability 1 pt.
 Welcome Banner/Closing message 1 pt.
Question 1 (7 pts.)
 Prompting user/reading data 2 pts.
 Decide the fare per km based on car model 1 pt.
 Decide the rush hour ratio 2 pts.
Compute the estimated fare 1 pt.
 Display correct results 1 pt.
Question 2 (7 pts.)
 Read in number 0.5 pt.
 Count number of the digits 2 pts.
 Reverse the digits 2 pts.
 Format the output 1 pt.
 Repetition 1.5 pts.
TOTAL 20 pts.

More products