ComputerScienceExpert

(11)

$18/per page/

About ComputerScienceExpert

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Applied Sciences,Calculus See all
Applied Sciences,Calculus,Chemistry,Computer Science,Environmental science,Information Systems,Science Hide all
Teaching Since: Apr 2017
Last Sign in: 12 Weeks Ago, 3 Days Ago
Questions Answered: 4870
Tutorials Posted: 4863

Education

  • MBA IT, Mater in Science and Technology
    Devry
    Jul-1996 - Jul-2000

Experience

  • Professor
    Devry University
    Mar-2010 - Oct-2016

Category > Programming Posted 04 May 2017 My Price 8.00

Write a program called RentalRate.java

I need help for this homework in Java language in the file.

 

 

Thank you 

 

 

Assignment 2: Conditional Processing
See Canvas for due date
40 Points (plus extra credit)
Write a program called RentalRate.java which reads in
a date of birth, today’s date and a male/female
designation from the user, and will then determine the
basic daily and weekly rates for rental of an economy
class car.
Rental rate classes are:
o Best rate (male drivers, age 33 – 65 and
female drivers, age 30 - 62) -- $40.00
per day, $200.00 per week
o Risk rate 1 (female drivers, age 25 – 29)
– Best rate plus $10.00 per day or best rate plus $55.00 per week.
o Risk rate 2 (male drivers, age 25 – 32) – Risk rate 1 plus $7.00 per day or risk rate
1 plus $30.00 per week.
o Risk rate 3 (male driver, age 66+ and female drivers, age 63+) – Best rate plus
$2.00 for each year over age 65 (male) or 62 (female), per day or best rate plus
$5.00 for each year over age 65 (male) or 62 (female), per week. PROGRAM PARTICULARS: When the program starts, ask the user for the renter’s gender – m or f. If not attempting extra credit, ask the user for today’s date Then ask the user for the renter’s month, day and year of birth (also see extra credit.) The program will determine the renter’s age and display:
o The renter’s gender and age o The renter’s rate class o The renter’s rate per day and per week. You may assume that user input provided will be valid for the base assignment (see Extra
Credit below.) Dates will be entered as individual integer values. Your program should be modular. Create separate methods for:
o Calculating age o Determining the rate class o Displaying the results. EXAMPLE RUN:
Welcome to the car renter's rate finder.
Please enter the renter’s gender (m/f): m
Please enter today's date (mm dd yyyy): 10 4 2011
Please enter the renter’s date of birth (mm dd yyyy): 1 22 1990
Thank you.
The male renter is 21 years old.
The rate class is: Sorry, the renter is not 25 years of age or
older. Welcome to the car renter's rate finder.
Please enter the renter’s gender (m/f): f
Please enter today's data (mm dd yyyy): 10 4 2011
Please enter the renter’s date of birth (mm dd yyyy): 11 1 1980
Thank you.
The female renter is 30 years old.
The rate class is: Best rate - $40.00 per day or $200.00 per
week.
Ï
Note: If you attempt the extra credit, your sample run will differ from the above listing as you will not
need to ask for today’s date, and invalid data will cause an error message to be displayed. HINTS: Be sure to test for ‘borderline’ cases. EXTRA CREDIT:
If you attempt the extra credit portion of the assignment, be sure to include a comment to the
grader.
5 points: Use the java.util.Date class to get the current date. DEPRECATED!!!
Note: The ‘Date’ class has been replaced with a more capable utility – the ‘Calendar’ class. Use
the Calendar class instead.
You must figure out how to use this Java library API yourself. Special Note: This assignment will provide you with a pre-written main() method. You must make your code conform to the pre-written main method:
//
//
//
// Rental rates assignment
Pre-set main for testing (see DEBUG constant)
Required methods to be added: calcAge(...), calcRateClass(...) and displayResult(...)
Also, insert code into main as indicated. import java.util.*;
public class RentalRates
{
private static final boolean DEBUG = true;
private
private
private
private static
static
static
static final
final
final
final String
String
String
String BEST_RATE = "Best rate - $40.00 per day or $200.00 per week.";
RISK_RATE_1= "Risk rate 1-$50.00 per day or $255.00 per week.";
RISK_RATE_2= "Risk rate 2-$57.00 per day or $285.00 per week.";
RISK_RATE_3= "Risk rate 3-$%4.2f per day or $%5.2f per week."; public static void main(String args)
{
int curMonth = 0;
int curDay = 0;
int curYear = 0;
int birthMonth = 0;
int birthDay = 0;
int birthYear = 0;
String gender = "";
int age = 0;
String rateResult;
// Testing mode...
if (DEBUG == true)
{
// Establish a 'current' date for testing...
curMonth = 2;
curDay = 1;
curYear = 2016;
System.out.println("First test case: Renter is not old enough to rent...");
birthMonth = 2;
birthDay = 2;
birthYear = 1991;
gender = "m";
age = calcAge(curMonth, curDay, curYear, birthMonth, birthDay, birthYear);
rateResult = calcRateClass(age, gender);
displayResults(gender, age, rateResult);
System.out.println("\nSecond test case: Renter is barely old enough (57/285)...");
birthMonth = 2;
birthDay = 1;
birthYear = 1991;
gender = "m";
age = calcAge(curMonth, curDay, curYear, birthMonth, birthDay, birthYear);
rateResult = calcRateClass(age, gender);
displayResults(gender, age, rateResult);
System.out.println("\nThird test case: Renter is 35 and male (40/200)...");
birthMonth = 1;
birthDay = 1;
birthYear = 1981;
gender = "m";
age = calcAge(curMonth, curDay, curYear, birthMonth, birthDay, birthYear);
rateResult = calcRateClass(age, gender);
displayResults(gender, age, rateResult);
System.out.println("\nFourth test case: Renter is 35 and female (40/200)...");
birthMonth = 1; birthDay = 1;
birthYear = 1981;
gender = "f";
age = calcAge(curMonth, curDay, curYear, birthMonth, birthDay, birthYear);
rateResult = calcRateClass(age, gender);
displayResults(gender, age, rateResult);
System.out.println("\nFifth test case: Renter is 30 and male (57/285)...");
birthMonth = 1;
birthDay = 1;
birthYear = 1986;
gender = "m";
age = calcAge(curMonth, curDay, curYear, birthMonth, birthDay, birthYear);
rateResult = calcRateClass(age, gender);
displayResults(gender, age, rateResult);
System.out.println("\nSixth test case: Renter is 30 and female (40/200)...");
birthMonth = 1;
birthDay = 1;
birthYear = 1986;
gender = "f";
age = calcAge(curMonth, curDay, curYear, birthMonth, birthDay, birthYear);
rateResult = calcRateClass(age, gender);
displayResults(gender, age, rateResult);
System.out.println("\nSeventh test case: Renter is 76 and male (62/255)...");
birthMonth = 1;
birthDay = 1;
birthYear = 1940;
gender = "m";
age = calcAge(curMonth, curDay, curYear, birthMonth, birthDay, birthYear);
rateResult = calcRateClass(age, gender);
displayResults(gender, age, rateResult);
System.out.println("\nEighth test case: Renter is 76 and female (68/270)...");
birthMonth = 1;
birthDay = 1;
birthYear = 1940;
gender = "f";
age = calcAge(curMonth, curDay, curYear, birthMonth, birthDay, birthYear);
rateResult = calcRateClass(age, gender);
displayResults(gender, age, rateResult);
}
else
{
Scanner kb = new Scanner(System.in);
System.out.println("Welcome to the car renter's rate finder.");
// If you're not attempting the EC, get today's date from the user...
//
Your code goes here...
// If you are attempting the EC, use the Calendar class to get today's date...
//
Your code goes here...
// Get the gender...
//
Your code goes here...
// Get the date of birth...
//
Your code goes here...
// Get age...
age = calcAge(curMonth, curDay, curYear, birthMonth, birthDay, birthYear);
// Get the rental rate...
rateResult = calcRateClass(age, gender);
// Display the results...
displayResults(gender, age, rateResult);
}
}
} TURN IN: (via the Canvas system)
A zip file containing your program source code. Hopefully you understand the naming scheme.
This zip file will contain: RentalRate.java -- contains your Java source code No test run is required for this assignment. Name your zip file LastNameFirstInitialHw2.zip

Attachments:

Answers

(11)
Status NEW Posted 04 May 2017 06:05 AM My Price 8.00

-----------

Not Rated(0)