Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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 (args.length > 0)
- {
- // Establish a 'current' date for testing...
- curMonth = 2;
- curDay = 1;
- curYear = 2012;
- System.out.println("First test case: Renter is not old enough to rent...");
- birthMonth = 2;
- birthDay = 2;
- birthYear = 1987;
- 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 = 1987;
- 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 = 1977;
- 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 = 1977;
- 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 = 1982;
- 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 = 1982;
- 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 = 1936;
- 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 (66/265)...");
- birthMonth = 1;
- birthDay = 1;
- birthYear = 1936;
- 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);
- } // End 'if args.length > 0'
- } // End main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement