Advertisement
Guest User

RentalRATESmainmethod

a guest
Jan 28th, 2012
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.71 KB | None | 0 0
  1.      public static void main(String[] args)
  2.       {    
  3.          int curMonth = 0;
  4.          int curDay = 0;
  5.          int curYear = 0;
  6.          int birthMonth = 0;
  7.          int birthDay = 0;
  8.          int birthYear = 0;
  9.          String gender = "";
  10.          int age = 0;
  11.          String rateResult;        
  12.        
  13.         // Testing mode... 
  14.          if (args.length > 0)
  15.          {
  16.             // Establish a 'current' date for testing...
  17.             curMonth = 2;
  18.             curDay = 1;
  19.             curYear = 2012;
  20.            
  21.             System.out.println("First test case: Renter is not old enough to rent...");
  22.             birthMonth = 2;
  23.             birthDay = 2;
  24.             birthYear = 1987;
  25.             gender = "m";
  26.             age = calcAge(curMonth, curDay, curYear, birthMonth, birthDay, birthYear);
  27.             rateResult = calcRateClass(age, gender);
  28.             displayResults(gender, age, rateResult);
  29.            
  30.             System.out.println("\nSecond test case: Renter is barely old enough (57/285)...");
  31.             birthMonth = 2;
  32.             birthDay = 1;
  33.             birthYear = 1987;
  34.             gender = "m";
  35.             age = calcAge(curMonth, curDay, curYear, birthMonth, birthDay, birthYear);
  36.             rateResult = calcRateClass(age, gender);
  37.             displayResults(gender, age, rateResult);
  38.            
  39.             System.out.println("\nThird test case: Renter is 35 and male (40/200)...");
  40.             birthMonth = 1;
  41.             birthDay = 1;
  42.             birthYear = 1977;
  43.             gender = "m";
  44.             age = calcAge(curMonth, curDay, curYear, birthMonth, birthDay, birthYear);
  45.             rateResult = calcRateClass(age, gender);
  46.             displayResults(gender, age, rateResult);
  47.          
  48.             System.out.println("\nFourth test case: Renter is 35 and female (40/200)...");
  49.             birthMonth = 1;
  50.             birthDay = 1;
  51.             birthYear = 1977;
  52.             gender = "f";
  53.             age = calcAge(curMonth, curDay, curYear, birthMonth, birthDay, birthYear);
  54.             rateResult = calcRateClass(age, gender);
  55.             displayResults(gender, age, rateResult);
  56.            
  57.             System.out.println("\nFifth test case: Renter is 30 and male (57/285)...");
  58.             birthMonth = 1;
  59.             birthDay = 1;
  60.             birthYear = 1982;
  61.             gender = "m";
  62.             age = calcAge(curMonth, curDay, curYear, birthMonth, birthDay, birthYear);
  63.             rateResult = calcRateClass(age, gender);
  64.             displayResults(gender, age, rateResult);
  65.            
  66.             System.out.println("\nSixth test case: Renter is 30 and female (40/200)...");
  67.             birthMonth = 1;
  68.             birthDay = 1;
  69.             birthYear = 1982;
  70.             gender = "f";
  71.             age = calcAge(curMonth, curDay, curYear, birthMonth, birthDay, birthYear);
  72.             rateResult = calcRateClass(age, gender);
  73.             displayResults(gender, age, rateResult);
  74.          
  75.             System.out.println("\nSeventh test case: Renter is 76 and male (62/255)...");
  76.             birthMonth = 1;
  77.             birthDay = 1;
  78.             birthYear = 1936;
  79.             gender = "m";
  80.             age = calcAge(curMonth, curDay, curYear, birthMonth, birthDay, birthYear);
  81.             rateResult = calcRateClass(age, gender);
  82.             displayResults(gender, age, rateResult);        
  83.          
  84.             System.out.println("\nEighth test case: Renter is 76 and female (66/265)...");
  85.             birthMonth = 1;
  86.             birthDay = 1;
  87.             birthYear = 1936;
  88.             gender = "f";
  89.             age = calcAge(curMonth, curDay, curYear, birthMonth, birthDay, birthYear);
  90.             rateResult = calcRateClass(age, gender);
  91.             displayResults(gender, age, rateResult);        
  92.          }
  93.          else
  94.          {
  95.             Scanner kb = new Scanner(System.in);
  96.             System.out.println("Welcome to the car renter's rate finder.");
  97.          
  98.          // If you're not attempting the EC, get today's date from the user...
  99.          //    Your code goes here...
  100.          
  101.          // If you are attempting the EC, use the Calendar class to get today's date...
  102.          //    Your code goes here...
  103.          
  104.          // Get the gender...
  105.          //    Your code goes here...
  106.          
  107.          // Get the date of birth...
  108.          //    Your code goes here...
  109.          
  110.          // Get age...
  111.             age = calcAge(curMonth, curDay, curYear, birthMonth, birthDay, birthYear);
  112.                
  113.             // Get the rental rate...
  114.             rateResult = calcRateClass(age, gender);
  115.                
  116.             // Display the results...
  117.             displayResults(gender, age, rateResult);
  118.          
  119.             }  // End 'if args.length > 0'
  120.         }  // End main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement