First part having no trouble with this
And this is the errors I'm getting.
UseCarRental.ja va:27: error: cannot find symbol
rentIt.display( );
^
symbol: method display()
location: variable rentIt of type LuxuryCarRental
UseCarRental.ja va:32: error: cannot find symbol
rentIt.display( );
^
symbol: method display()
location: variable rentIt of type CarRental
UseCarRental.ja va:37: error: cannot find symbol
double fee = totalFee(carSiz e);
^
symbol: variable carSize
location: class UseCarRental
UseCarRental.ja va:38: error: cannot find symbol
System.out.prin tln("Renters Name: " + name);
^
symbol: variable name
location: class UseCarRental
UseCarRental.ja va:39: error: cannot find symbol
System.out.prin tln("Renters Zip Code:" + zipCode);
^
symbol: variable zipCode
location: class UseCarRental
UseCarRental.ja va:40: error: cannot find symbol
System.out.prin tln("Car Rented:" + carSize );
^
symbol: variable carSize
location: class UseCarRental
UseCarRental.ja va:42: error: cannot find symbol
System.out.prin tln("Total Days Rented:" + daysRented);
^
symbol: variable daysRented
location: class UseCarRental
UseCarRental.ja va:43: error: cannot find symbol
double days = (double)daysren ted;
^
symbol: variable daysrented
location: class UseCarRental
UseCarRental.ja va:44: error: cannot find symbol
totalFee = (fee * days) + (chaufferFee * days);
^
symbol: variable totalFee
location: class UseCarRental
UseCarRental.ja va:44: error: cannot find symbol
totalFee = (fee * days) + (chaufferFee * days);
^
symbol: variable chaufferFee
location: class UseCarRental
UseCarRental.ja va:46: error: cannot find symbol
String trf = df.format(total Fee);
^
symbol: variable totalFee
location: class UseCarRental
UseCarRental.ja va:47: error: cannot find symbol
System.out.prin tln("Total Fee:" + tf);
^
symbol: variable tf
location: class UseCarRental
12 errors
Code:
public class CarRental
{
private String name = "";
private int zipCode = 00000;
private String carSize = "";
private int daysRented = 0;
private double totalFee = 0.00;
private String chauffer = "";
double chaufferFee = 0000.00;
public CarRental(String n, int zc, String cs, int dr)
{
name = n;
zipCode = zc;
carSize = cs;
daysRented = dr;
}
private double RentalFee(String carsize)
{
double fee = 0.00;
if(carsize.equals("economy"))
{
fee = 29.99;
}
else if(carsize.equals("midsize"))
{
fee = 38.99;
}
else if(carsize.equals("fullsize"))
{
fee = 43.50;
}
else if(carsize.equals("luxury"))
{
fee = 79.99;
}
return fee;
}
}
Second part also no trouble with this.
public class LuxuryCarRental extends CarRental
{
public LuxuryCarRental(String n, int zc, String cs, int dr, String ch)
{
super(n, zc, cs, dr);
if (ch.equals("y"))
chaufferFee = 200.00;
}
}
Final part is where the trouble is..
import java.util.*;
import java.text.*;
public class UseCarRental
{
public static void main(String args[])
{
Scanner input = new Scanner(System.in);
System.out.println("Enter your full name: ");
input.next();
String name = input.nextLine();
System.out.println("Enter your zip code: ");
int zipCode = input.nextInt();
System.out.println("Enter the car size you would like to rent: \n"
+ "economy\n"
+ "midsize\n"
+ "fullsize\n"
+ "luxury?");
String carSize = input.next();
System.out.println("How many days would you like to rent this vechile for?");
int daysRented = input.nextInt();
if (carSize.equals("luxury"))
{
System.out.println("Would you like a chauffer? (y or n)");
String chauffer = input.next();
LuxuryCarRental rentIt = new LuxuryCarRental(name, zipCode, carSize,
daysRented, chauffer);
rentIt.display();
}
else
{
CarRental rentIt = new CarRental(name, zipCode, carSize, daysRented);
rentIt.display();
}
}
private void display()
{
double fee = totalFee(carSize);
System.out.println("Renters Name: " + name);
System.out.println("Renters Zip Code:" + zipCode);
System.out.println("Car Rented:" + carSize );
System.out.println("Daily Rental Fee:" + fee);
System.out.println("Total Days Rented:" + daysRented);
double days = (double)daysrented;
totalFee = (fee * days) + (chaufferFee * days);
DecimalFormat df = new DecimalFormat("#.##");
String trf = df.format(totalFee);
System.out.println("Total Fee:" + tf);
}
}
UseCarRental.ja va:27: error: cannot find symbol
rentIt.display( );
^
symbol: method display()
location: variable rentIt of type LuxuryCarRental
UseCarRental.ja va:32: error: cannot find symbol
rentIt.display( );
^
symbol: method display()
location: variable rentIt of type CarRental
UseCarRental.ja va:37: error: cannot find symbol
double fee = totalFee(carSiz e);
^
symbol: variable carSize
location: class UseCarRental
UseCarRental.ja va:38: error: cannot find symbol
System.out.prin tln("Renters Name: " + name);
^
symbol: variable name
location: class UseCarRental
UseCarRental.ja va:39: error: cannot find symbol
System.out.prin tln("Renters Zip Code:" + zipCode);
^
symbol: variable zipCode
location: class UseCarRental
UseCarRental.ja va:40: error: cannot find symbol
System.out.prin tln("Car Rented:" + carSize );
^
symbol: variable carSize
location: class UseCarRental
UseCarRental.ja va:42: error: cannot find symbol
System.out.prin tln("Total Days Rented:" + daysRented);
^
symbol: variable daysRented
location: class UseCarRental
UseCarRental.ja va:43: error: cannot find symbol
double days = (double)daysren ted;
^
symbol: variable daysrented
location: class UseCarRental
UseCarRental.ja va:44: error: cannot find symbol
totalFee = (fee * days) + (chaufferFee * days);
^
symbol: variable totalFee
location: class UseCarRental
UseCarRental.ja va:44: error: cannot find symbol
totalFee = (fee * days) + (chaufferFee * days);
^
symbol: variable chaufferFee
location: class UseCarRental
UseCarRental.ja va:46: error: cannot find symbol
String trf = df.format(total Fee);
^
symbol: variable totalFee
location: class UseCarRental
UseCarRental.ja va:47: error: cannot find symbol
System.out.prin tln("Total Fee:" + tf);
^
symbol: variable tf
location: class UseCarRental
12 errors
Comment