The goal of the project is to calc based on age and gender there rental rates for cars. but something is going terribly wrong T-T.
I am receiving the following errors in homework for java class.
----jGRASP exec: javac -g RentalRate.java
RentalRate.java:112: error: illegal start of expression
public static String getGender(gender, Scanner kb)
^
RentalRate.java:112: error: illegal start of expression
public static String getGender(gender, Scanner kb)
^
RentalRate.java:112: error: ';' expected
public static String getGender(gender, Scanner kb)
^
RentalRate.java:112: error: ')' expected
public static String getGender(gender, Scanner kb)
^
RentalRate.java:112: error: illegal start of expression
public static String getGender(gender, Scanner kb)
^
RentalRate.java:112: error: ';' expected
public static String getGender(gender, Scanner kb)
^
RentalRate.java:128: error: illegal start of expression
public static int calcAge( curMonth, curDay, curYear, birthMonth, birthDay, birthYear)
^
RentalRate.java:128: error: illegal start of expression
public static int calcAge( curMonth, curDay, curYear, birthMonth, birthDay, birthYear)
^
RentalRate.java:128: error: ';' expected
public static int calcAge( curMonth, curDay, curYear, birthMonth, birthDay, birthYear)
^
RentalRate.java:128: error: ';' expected
public static int calcAge( curMonth, curDay, curYear, birthMonth, birthDay, birthYear)
^
RentalRate.java:150: error: illegal start of expression
public static String calcRateClass(age, gender)
^
RentalRate.java:150: error: illegal start of expression
public static String calcRateClass(age, gender)
^
RentalRate.java:150: error: ';' expected
public static String calcRateClass(age, gender)
^
RentalRate.java:150: error: ';' expected
public static String calcRateClass(age, gender)
^
RentalRate.java:191: error: illegal start of expression
public static String displayResults(gender, age, rateResult)
^
RentalRate.java:191: error: illegal start of expression
public static String displayResults(gender, age, rateResult)
^
RentalRate.java:191: error: ';' expected
public static String displayResults(gender, age, rateResult)
^
RentalRate.java:191: error: ';' expected
public static String displayResults(gender, age, rateResult)
^
RentalRate.java:219: error: class, interface, or enum expected
}//end class
^
19 errors
----jGRASP wedge2: exit code for process is 1.
----jGRASP: operation complete.
Here is the code
import java.util.Calendar;
import java.util.Scanner;
public class RentalRate
{
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...
public static String getGender(gender, Scanner kb)
{
System.out.println("Please enter the renter's gender (m/f): ");
gender = kb.nextLine();
if(gender != 'm' || gender != 'f')
{
System.out.println("Please enter a valid entry for gender (m/f)");
}
else
{
return gender;
}
}
// Get the date of birth...
// Your code goes here...
public static int calcAge( curMonth, curDay, curYear, birthMonth, birthDay, birthYear)
{
System.out.println("Please enter the renter's date of birth (mm d yyyy)");
curMonth = kb.nextInt();
curDay = kb.nextInt();
curYear = kb.nextInt();
System.out.println("Thank you");
int age = curYear-birthYear;
if(birthMonth>curMonth)
{
age--;
}
else if(birthMonth=curMonth&& BirthDay> curDay)
{
age--;
}
return age;
} //end calcAge
public static String calcRateClass(age, gender)
{
if(gender == 'm' || gender == 'M')//check for gender
{
if(age < 33 && age > 24)
{
return System.out.println(" Risk rate 2: $57.00 per day or $285.00 per week.");
}
else if(age > 32 && age < 66)
{
return System.out.println(" Best rate: 40.00 per day or $200.00 per week.");
}
else if(age > 65)
{
return System.out.println(" Risk rate 3: $" + (((age-65)*2.00)+40.00) + " per day or $" + (((age-65)*5.00)+200.00) + " per week.");
}
else
{
return System.out.println(" Sorry, the renter is not 25 years of age or older.");
}
}
else// female
{
if(age < 30 && age > 24)
{
return System.out.println(" Risk rate 1: $50.00 per day or $255.00 per week.");
}
else if(age > 29 && age < 63)
{
return System.out.println("Best rate: $40.00 per day or $200.00 per week.");
}
else if(age > 62)
{
return System.out.println(" Risk rate 3: $" + (((age-62)*2.00)+40) + " per day or $" +(((age-62)*5.00)+200.00) + " per week.");
}
else
{
return System.out.println( " Sorry, the renter is not 25 years of age or older.");
}
}
}//end method calcrateclass
public static String displayResults(gender, age, rateResult)
{
System.out.println("Thank you");
String realGender = " ";
if (gender == 'm' || gender == 'M')
{
realGender = "male";
}
else if(gender == 'f' || gender == 'F')
{
realGender ="female";
}
System.out.println("The " + realGender + " renter is " + age + " years old.");
System.out.println(rateResult);
}
// 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()
}//end class