-
November 24th, 2010, 03:26 PM
#1
Java problems - please help
Wings Coffee Shop
A local coffee shop sells a variety of different items shown below to their customers. You are asked to write a Java application that can be used to keep track of these items. Additionally, this program provides a way to print out a listing of the items.
Item Name Price
Coffee $1.00
Water $2.00
Milk $1.50
Bagel $1.25
Donut $0.75
Your program will create a class, named Item. This class has the following:
* A String instance variable to hold the item name
* A double instance variable to hold the price
* A constructor that takes a String and double to initialize the instance variables
* A get and set method for each instance variable
________________________________________________________________________
here is my crappy code so far...
________________________________________________________________________
public class Unit10Final
{
private double price;
private String items;
public double price()
{
return price;
}
public String items()
{
return items;
}
}
public class SaleDetails
{
double[] price = {1.00, 2.00, 1.50, 1.25, .75};
String[] items = {"Coffee", "Water", "Milk", "Bagel", "Donut"};
}
// public static void main(String[] args)
public class printit
{
public static void main(String[] args);
{
double[] price = {1.00, 2.00, 1.50, 1.25, .75};
String[] items = {"Coffee", "Water", "Milk", "Bagel", "Donut"};
system.out.println("Item Name Price");
system.out.println items[0], " ",price[0];
system.out.println items[1], " ",price[1];
system.out.println items[2], " ",price[2];
system.out.println items[3], " ",price[3];
system.out.println items[4], " ",price[4];
}
}
-
November 28th, 2010, 02:39 PM
#2
Re: Java problems - please help
Your program will create a class, named Item. This class has the following:...
So where is this bit of code?
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|