CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2010

    Exclamation 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];

  2. #2
    Join Date
    May 2006

    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?
    Posting code? Use code tags like this: [code]...Your code here...[/code]
    Click here for examples of Java 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

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.