There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Tag Cloud
acer black screen blue screen boot bsod computer connection crash css dell display driver drivers email error excel explorer firefox firefox 3 game hard drive internet internet explorer itunes laptop lcd linux malware network networking nvidia outlook outlook 2003 outlook express partition printer problem ram router slow sound trojan usb video virus vista windows windows vista windows xp wireless
Software Development
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Software & Hardware > Software Development >
Help with used car program (java)


HELLO AND WELCOME! Before you can post your question, you'll have to register -- it's completely free! Click here to join today! We highly recommend that you print a copy of our Guide for New Members. Enjoy!

Closed Thread
 
Thread Tools
Twista's Avatar
Junior Member with 3 posts.
 
Join Date: Mar 2004
05-Mar-2004, 10:56 PM #1
Help with used car program (java)
I need to create two classes, one called car (this is the actual car object) and one called carlist (this is an array of cars which are for sale). I of course also need to create an additional driver class for the program (this will contain the main method which will create objects and call their methods, and I need to use the keyboard class to get input from the user).

The program should be capable of providing the following user experience:

ACME Used Car Dealers

1. Purchase car
2. Display cars for sale
3. Sell car

Enter option: 1

PURCHASE CAR
MAKE: Ford
Model: Escort
Year: 2001
Miles: 3400
Color: White
Purchase price: 1500
Sale price: 2495

1. Purchase car
2. Display cars for sale
3. Sell car

Enter option: 2

CARS FOR SALE

No Make Model Year Miles Color Price
1 Ford Escort 2001 3400 White 2495
2 Saab 93 2000 56000 Black 4999

1. Purchase car
2. Display cars for sale
3. Sell car

Enter option: 3

SELL A CAR
Which car: 1
What price: 2395
Sold a White Ford Escort 2001
You just made us $895 profit


BTW, each car object should store (at a minimum) the following information:

-make
-model
-year
-miles
-color
-purchase price
-for sale price
-sold flag

The carlist object will be an array of cars and a pointer to the next free location in the array for the next car to go in

I would appreciate any sort of help
MustBNuts's Avatar
Senior Member with 1,930 posts.
 
Join Date: Aug 2003
Location: Nevada
06-Mar-2004, 01:11 AM #2
what sort of code do you have so far? when is the assignment due?
Twista's Avatar
Junior Member with 3 posts.
 
Join Date: Mar 2004
06-Mar-2004, 01:22 AM #3
Thanks for the response

Here is the code I have so far for the car class


import java.text.NumberFormat;
public class Car
{
// Give types for all the variables
private String make;
private String model;
private int year;
private int miles;
private String color;
private int price

// Constructor with parameters
// Create a new car with the given attributes
public Car(String make,String model,int year,int miles,String color,int price)
{
this.make = make;
this.model = model;
this.year = year;
this.miles = miles;
this.color = color;
this.price = price;
}


// GETTERS!!!!
public String getMake()
{
return make;
}

public String getModel()
{
return model;
}

public int getYear()
{
return year;
}

public int getMiles()
{
return miles;
}

public String getColor()
{
return color;
}

public int getPrice()
{
return price;
}

public static void main (String[] args)
{
Car car1 = new Car("Ford","Escort",2001,34000,"White",2495);
Car car2 = new Car("Saab","93",2000,56000,"Black",4999);
System.out.println("car1.getMake()+" "+car1.getModel()+" "car1.getYear()+" "+car1.getMiles()+" "+car1.getColor()+" "+car1.getPrice());
System.out.println("car2.getMake()+" "+car2.getModel()+" "car2.getYear()+" "+car2.getMiles()+" "+car2.getColor()+" "+car2.getPrice());

}



}








BTW, the assignment is due tuesday
MustBNuts's Avatar
Senior Member with 1,930 posts.
 
Join Date: Aug 2003
Location: Nevada
06-Mar-2004, 01:04 PM #4
Okay, I figured it was homework. If you do a search on this forum with keyword homework, you will find that we don't do it here....

If you are having specific problems, please post your question. A post that says "this is what I need" implies you are waiting for someone to write the code for you. It won't happen here...sorry!

MBN
__________________
I'll burn that bridge when I get to it!
Twista's Avatar
Junior Member with 3 posts.
 
Join Date: Mar 2004
06-Mar-2004, 01:39 PM #5
okay, I never expected anybody to do this for me. I just need assistance.

Is this right?

CarList [] carlist = new CarList[2]; carlist [0] = new CarList(); carlist [1] = new CarList(); carlist [0].make = "Ford"; carlist [0].model = "Escort"; carlist [0].year = 2001; carlist [0].miles = 3400; carlist [0].color = "White"; carlist [0].price = 2495; carlist [1].make = "Saab"; carlist [1].model = "93"; carlist [1].year = 2000; carlist [1].miles = 56000; carlist [1].color = "Black"; carlist [1].price = 4999;
Closed Thread

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who help people like you solve computer problems. See our Welcome Guide to get started.



Thread Tools


You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 05:02 PM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.