473,406 Members | 2,343 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Trouble with UseCarRental program I have to write

First part having no trouble with this
Expand|Select|Wrap|Line Numbers
  1. public class CarRental
  2. {
  3.    private String name = "";
  4.    private int zipCode = 00000;
  5.    private String carSize = "";
  6.    private int daysRented = 0;
  7.    private double totalFee = 0.00;
  8.    private String chauffer = "";
  9.    double chaufferFee = 0000.00;
  10.    public CarRental(String n, int zc, String cs, int dr)
  11.    {
  12.       name = n;
  13.       zipCode = zc;
  14.       carSize = cs;
  15.       daysRented = dr;
  16.    }
  17.  
  18.    private double RentalFee(String carsize)
  19.    {
  20.       double fee = 0.00;
  21.       if(carsize.equals("economy"))
  22.       {
  23.          fee = 29.99;
  24.       }
  25.       else if(carsize.equals("midsize"))
  26.       {
  27.          fee = 38.99;
  28.       }
  29.       else if(carsize.equals("fullsize"))
  30.       {
  31.          fee = 43.50;
  32.       }
  33.       else if(carsize.equals("luxury"))
  34.       {
  35.          fee = 79.99;
  36.       }
  37.       return fee;
  38.    }
  39. }
  40. Second part also no trouble with this.
  41. public class LuxuryCarRental extends CarRental
  42. {
  43.    public LuxuryCarRental(String n, int zc, String cs, int dr, String ch)
  44.    {
  45.       super(n, zc, cs, dr);
  46.       if (ch.equals("y"))
  47.          chaufferFee = 200.00;
  48.    }
  49. }
  50. Final part is where the trouble is..
  51. import java.util.*;
  52. import java.text.*;
  53. public class UseCarRental
  54. {
  55.    public static void main(String args[])
  56.    {
  57.       Scanner input = new Scanner(System.in);
  58.       System.out.println("Enter your full name: ");
  59.       input.next();
  60.       String name = input.nextLine();
  61.       System.out.println("Enter your zip code: ");
  62.       int zipCode = input.nextInt();
  63.       System.out.println("Enter the car size you would like to rent: \n"
  64.             + "economy\n"
  65.             + "midsize\n"
  66.             + "fullsize\n"
  67.             + "luxury?");
  68.       String carSize = input.next();
  69.       System.out.println("How many days would you like to rent this vechile for?");
  70.       int daysRented = input.nextInt();
  71.       if (carSize.equals("luxury"))
  72.       {
  73.          System.out.println("Would you like a chauffer? (y or n)");
  74.          String chauffer = input.next();
  75.          LuxuryCarRental rentIt = new LuxuryCarRental(name, zipCode, carSize, 
  76.          daysRented, chauffer);
  77.          rentIt.display();
  78.       }
  79.       else
  80.       {
  81.          CarRental rentIt = new CarRental(name, zipCode, carSize, daysRented);
  82.          rentIt.display();
  83.       }
  84. }
  85.       private void display()
  86.       {
  87.          double fee = totalFee(carSize);
  88.          System.out.println("Renters Name: " + name);
  89.          System.out.println("Renters Zip Code:" + zipCode);
  90.          System.out.println("Car Rented:" + carSize );
  91.          System.out.println("Daily Rental Fee:" + fee);
  92.          System.out.println("Total Days Rented:" + daysRented);
  93.          double days = (double)daysrented;
  94.          totalFee = (fee * days) + (chaufferFee * days);
  95.          DecimalFormat df = new DecimalFormat("#.##");
  96.          String trf = df.format(totalFee);
  97.          System.out.println("Total Fee:" + tf);
  98.       }
  99.    }
And this is the errors I'm getting.
UseCarRental.java:27: error: cannot find symbol
rentIt.display();
^
symbol: method display()
location: variable rentIt of type LuxuryCarRental
UseCarRental.java:32: error: cannot find symbol
rentIt.display();
^
symbol: method display()
location: variable rentIt of type CarRental
UseCarRental.java:37: error: cannot find symbol
double fee = totalFee(carSize);
^
symbol: variable carSize
location: class UseCarRental
UseCarRental.java:38: error: cannot find symbol
System.out.println("Renters Name: " + name);
^
symbol: variable name
location: class UseCarRental
UseCarRental.java:39: error: cannot find symbol
System.out.println("Renters Zip Code:" + zipCode);
^
symbol: variable zipCode
location: class UseCarRental
UseCarRental.java:40: error: cannot find symbol
System.out.println("Car Rented:" + carSize );
^
symbol: variable carSize
location: class UseCarRental
UseCarRental.java:42: error: cannot find symbol
System.out.println("Total Days Rented:" + daysRented);
^
symbol: variable daysRented
location: class UseCarRental
UseCarRental.java:43: error: cannot find symbol
double days = (double)daysrented;
^
symbol: variable daysrented
location: class UseCarRental
UseCarRental.java:44: error: cannot find symbol
totalFee = (fee * days) + (chaufferFee * days);
^
symbol: variable totalFee
location: class UseCarRental
UseCarRental.java:44: error: cannot find symbol
totalFee = (fee * days) + (chaufferFee * days);
^
symbol: variable chaufferFee
location: class UseCarRental
UseCarRental.java:46: error: cannot find symbol
String trf = df.format(totalFee);
^
symbol: variable totalFee
location: class UseCarRental
UseCarRental.java:47: error: cannot find symbol
System.out.println("Total Fee:" + tf);
^
symbol: variable tf
location: class UseCarRental
12 errors
Nov 14 '13 #1
4 3088
r035198x
13,262 8TB
1.) You are calling the display method on the Car rental object but the method is not in the Car rental class. So move that method to the CarRental class.
2.) If you want to be able to call that method outside that class then you need to make it public too.
3.) You have a line
Expand|Select|Wrap|Line Numbers
  1. double days = (double)daysrented;
which is incorrect because the variable called daysRented (with a capital R). Java is case sensitive.
4.) You have another incorrect line with
Expand|Select|Wrap|Line Numbers
  1. double fee = totalFee(carSize);
What are you trying to achieve with that?
5.) You also have another typing mistake with
Expand|Select|Wrap|Line Numbers
  1.  System.out.println("Total Fee:" + tf);
which should be
Expand|Select|Wrap|Line Numbers
  1. System.out.println("Total Fee:" + trf);
Nov 14 '13 #2
ok so i fixed some of the issues but i don't understand what you mean by #1 and 2 with the methods.
Nov 14 '13 #3
r035198x
13,262 8TB
You have
Expand|Select|Wrap|Line Numbers
  1. CarRental rentIt = new CarRental(name, zipCode, carSize, daysRented);
  2. rentIt.display();
For you to call the method rentIt.display(), it must be in the CarRental class because you are calling it on rentIt which is a reference to an object of the CarRental class. In your code that method is in the UseCarRental class instead so that won't work.
Nov 15 '13 #4
itsraghz
127 100+
Look at the lines 75 to 77 in your code pasted above.

Expand|Select|Wrap|Line Numbers
  1. LuxuryCarRental rentIt = new LuxuryCarRental(name, zipCode, carSize, 
  2.          daysRented, chauffer);
  3.          rentIt.display();
  4.  
Whereas the object rentIt is of type LuxuryCarRental. But the class LuxuryCarRental does not have a method 'display'. Hence the error.
Nov 15 '13 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Tatjana Vasileva | last post by:
Hi Everyone, I have installed .NET framework 1.1 with SP1, as well as MDE 2003 (v. 7.1.3088) on my local machine. When I try to add new item (class, form, service, ...) to an existing VB.NET...
3
by: Bore Biko | last post by:
Dear, I don't have enought money to by a original Visual C++, so I use Visual C++ 6.0 Enterprise edition, this version doesen't have a HELP. Most of my friends programmers praise C++, as a...
4
by: puzzlecracker | last post by:
I am using cpp by the way? Thanks
11
by: TheBurgerMan | last post by:
Hi all. I am using W2K3, .NET2 on a machine running AD and Exchange. I started getting the message below last week. I googled the error and not much was returned, but I did find this;...
0
by: Cleyton | last post by:
Hello! Someone knows what is happening?... My program doesn't work running in guest account. My program is registrated in msconfig and starts with windows...Ok... So, it stays waiting for a...
3
by: plbaldri | last post by:
I have written a very simple and basic program for an intro Comp Sci class and am having trouble with it crashing. The program needs to accept a filename on the command line at the prompt and has to...
6
by: priyajohal | last post by:
#include<fstream.h> #include<process.h> #include<stdlib.h> #include<conio.h> #include<string.h> #include<dos.h> #include<ctype.h> #include<stdio.h> void setup() void help();
1
by: mamul | last post by:
Hi All, I am able to read and write to .txt, .bin files. but the same program is not support for .docx file . can someone help me the procedure to perform read write operation on .docx file. ...
1
by: btreddy | last post by:
Hii all , When i was trying to access the webpages from the server(localhost only ) I got the message "The current identity (SYSNAME\ASPNET) does not have write access to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.