Page 1 of 2 12 LastLast
Results 1 to 20 of 34
  1. #1
    Quizzle23 is offline Member
    Join Date
    Feb 2011
    Posts
    34
    Rep Power
    0

    Default Driving me crazy!!!! Please help!!

    Please help I need this code is print the following:


    These are the current items on hand: Jacket, Designer Jeans & Shirt
    Here is the current stock on each item: Jacket:12 Designer Jeans:40 Shirt:20
    Below you will find the current item prices: Jacket:59.95 Designer Jeans:34.95
    Shirt:24.95

    This is what it is saying right now:
    These are the current items on hand:

    Here is the current stock on each item: Jacket:12 Designer Jeans:40 Shirt:20
    Below you will find the current item prices: Jacket:59.95 Designer Jeans:34.95
    Shirt:24.95

    HERE IS THE CODE:
    1 OF 2
    public class RetailItem {

    private String description1;
    private String description2;
    private String description3;
    private int unitsOnHand1;
    private int unitsOnHand2;
    private int unitsOnHand3;
    private double retailPrice1;
    private double retailPrice2;
    private double retailPrice3;

    public RetailItem (String item1,String item2,String item3, int onHand1,int onHand2,int onHand3, double price1, double price2, double price3) {
    description1 = item1;
    description2 = item2;
    description3 = item3;
    unitsOnHand1 = onHand1;
    unitsOnHand2 = onHand2;
    unitsOnHand3 = onHand3;
    retailPrice1 = price1;
    retailPrice2 = price2;
    retailPrice3 = price3;
    }

    public void setDescription(String item1,String item2,String item3)
    {
    description1 = item1;
    description2 = item2;
    description3 = item3;
    }

    public void setUnitsOnHand(int onHand1,int onHand2,int onHand3)
    {
    unitsOnHand1 = onHand1;
    unitsOnHand2 = onHand2;
    unitsOnHand3 = onHand3;
    }

    public void setRetailPrice(double price1,double price2, double price3 )
    {
    retailPrice1 = price1;
    retailPrice2 = price2;
    retailPrice3 = price3;
    }

    public String getDescription1()
    {
    return description1;
    }

    public String getDescription2()
    {
    return description2;
    }

    public String getDescription3()
    {
    return description3;
    }

    public int getUnitsOnHand1()
    {
    return unitsOnHand1;
    }

    public int getUnitsOnHand2()
    {
    return unitsOnHand2;
    }

    public int getUnitsOnHand3()
    {
    return unitsOnHand3;
    }

    public double getRetailPrice1()
    {
    return retailPrice1;
    }

    public double getRetailPrice2()
    {
    return retailPrice2;
    }

    public double getRetailPrice3()
    {
    return retailPrice3;
    }
    }

    2 OF 2:
    import java.util.Scanner;

    public class RetailItemTest
    {
    public static void main(String [] args)
    {
    String testItem1;
    String testItem2;
    String testItem3;
    int testOnHand1 = 12;
    int testOnHand2 = 40;
    int testOnHand3 = 20;
    double testPrice1 = 59.95;
    double testPrice2 = 34.95;
    double testPrice3 = 24.95;

    Scanner keyboard = new Scanner(System.in);

    System.out.print("These are the current items on hand: ");
    testItem1 = keyboard.nextLine();
    testItem2 = keyboard.nextLine();
    testItem3 = keyboard.nextLine();

    System.out.print("Here is the current stock on each item: Jacket:" + testOnHand1 + "\nDesigner Jeans:" + testOnHand2 +
    "\nShirt:" + testOnHand3);


    System.out.print("Below you will find the current item prices: Jacket:" + testPrice1 + "\nDesigner Jeans:" + testPrice2 +
    "\nShirt:" + testPrice3);


    }
    }

  2. #2
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,755
    Rep Power
    7

    Default

    Do you have a question or should we just read your mind?

  3. #3
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,755
    Rep Power
    7

    Default

    Java Code:
    public class RetailItem {
    
    private String description1;
    private String description2;
    private String description3;
    private int unitsOnHand1;
    private int unitsOnHand2;
    private int unitsOnHand3;
    private double retailPrice1;
    private double retailPrice2;
    private double retailPrice3;
    Let me ask you, for a Car to exist does it need to know the details of every other Car that exists on the planet? How about if you want a fourth item such as a Sweater? Will you add another set of variables to hold information about the Sweater?

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default

    Poster, please don't post a "here is my code, here is my assignment, fix it for me". As requested above, please ask a specific answerable question.

  5. #5
    al_Marshy_1981 is offline Senior Member
    Join Date
    Feb 2010
    Location
    Waterford, Ireland
    Posts
    748
    Rep Power
    5

    Default

    println all that information you took in ie testItem1, testItem2 etc. I am assuming you entered jacket etc for these?

    Java Code:
    testItem1 = keyboard.nextLine();
    testItem2 = keyboard.nextLine();
    testItem3 = keyboard.nextLine();

  6. #6
    Quizzle23 is offline Member
    Join Date
    Feb 2011
    Posts
    34
    Rep Power
    0

    Default

    Never mind, I figured it out but thanks.

  7. #7
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    8

    Default

    Sounds like someone failed his assignment because nobody was willing to help him cheat. Well, as they say, you get what you deserve.

  8. #8
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    8

    Default

    Then why so bitter?

  9. #9
    Join Date
    Jan 2011
    Posts
    13
    Rep Power
    0

    Default

    Why not just use an array for the retaill prices, unitsOnHand , and desriptions??
    Last edited by biggerthanblue; 02-21-2011 at 04:41 PM.

  10. #10
    Join Date
    Jan 2011
    Posts
    13
    Rep Power
    0

    Default

    Java Code:
    private String desriptions[]={"", "", "", "",};
    private int unitsOnHand[]={0, 1, 2, 3};
    private double retailprices[]={0.0, 1.1, 2.2, 3.3};
    just a tip

  11. #11
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    12,998
    Blog Entries
    7
    Rep Power
    19

    Default

    Quote Originally Posted by biggerthanblue View Post
    Java Code:
    private String desriptions[]={"", "", "", "",};
    private int unitsOnHand[]={0, 1, 2, 3};
    private double retailprices[]={0.0, 1.1, 2.2, 3.3};
    just a tip
    Your tip is so Fortranesque. Better build a class X that holds a descriptiom a unitsOnHand and a retailPrice and have some sort of collection of X objects.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  12. #12
    Quizzle23 is offline Member
    Join Date
    Feb 2011
    Posts
    34
    Rep Power
    0

    Default

    Quote Originally Posted by masijade View Post
    Sounds like someone failed his assignment because nobody was willing to help him cheat. Well, as they say, you get what you deserve.
    No one is upset and I was not cheating, just trying to find an easier way to display my code. Oh by the way 1 I'm not a dude and 2 I got an A.

    Anyways for those who are not jerks. How would I divide 3 different items?
    For instance:

    If testDays needs to equal testWidgets / testHours / testProduction. How would it be formatted? I have tried everything in my book but it will not compile. Thanks in advance

  13. #13
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,755
    Rep Power
    7

    Default

    I was going to help but then realised that I am probably one of the jerks.

  14. #14
    Quizzle23 is offline Member
    Join Date
    Feb 2011
    Posts
    34
    Rep Power
    0

    Default

    Wow really wasn't talking about you but ok.

  15. #15
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,755
    Rep Power
    7

    Default

    Either way do you think it is a good idea to abuse those you are asking for help?

  16. #16
    Quizzle23 is offline Member
    Join Date
    Feb 2011
    Posts
    34
    Rep Power
    0

    Default

    Masijade was not helping me at all, all he or she was doing was being a jerk. I don't know if you agree or disagree with him or her but the point remains I stated I figured it out so no one would waste their time in responding. Either way do you think it's a good idea did for someone who is in fact a beginner looking for help to have someone be jerk to them while trying to learn?? That's what this place is somewhere for someone who has a question to ask it, get an answer and understand it. Not to go through the BS of someone who thinks they are better then everyone else. Duh that is why I'm here I know someone on here knows more then I, hence the reason I asked the question.

  17. #17
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default

    He was not criticizing your asking a question, but how you didn't ask it. There really was no question in your original post, but just your assignment and some non-working code which here is called a homework dump or a code dump. I think most folks here will bend over backwards to help you if you put the same amount of effort in asking your question (and in asking an actual question) that you're requesting that they expend in answering it. But asking a question is a learned art, and you will get better at it with time and effort.

    Best of luck.

  18. #18
    Quizzle23 is offline Member
    Join Date
    Feb 2011
    Posts
    34
    Rep Power
    0

    Default

    Your right but stating I was angry or upset b/c no one answered my question was incorrect. I figured it out it's that simple. To say I failed my assignment and that I get what I deserve and that I'm bitter is ridiculous. I understand how I need to phrase my questions but what he or she wrote had nothing to do with how my question was phrased or helping me.


    Sounds like someone failed his assignment because nobody was willing to help him cheat. Well, as they say, you get what you deserve.

  19. #19
    goldest's Avatar
    goldest is offline Senior Member
    Join Date
    Oct 2009
    Location
    Pune, India
    Posts
    469
    Rep Power
    5

    Wink

    Quote Originally Posted by Quizzle23 View Post
    Your right but stating I was angry or upset b/c no one answered my question was incorrect. I figured it out it's that simple. To say I failed my assignment and that I get what I deserve and that I'm bitter is ridiculous. I understand how I need to phrase my questions but what he or she wrote had nothing to do with how my question was phrased or helping me.


    Sounds like someone failed his assignment because nobody was willing to help him cheat. Well, as they say, you get what you deserve.
    Well well well... These seems to be some kind of mis-understanding here.

    Quizzle23,

    Yesterday there was a internet troll [named AnyJavaPros] spamming all over the place in this forum. He was randomly interrupting genuine threads. The 2 responses that Masijade had in this thread were in response to that spammer's abusive posts and NOT related to you or your questions. You can't see the spammer's posts because he has been banned permanently and his posts were deleted by Moderators.

    Masijade isn't a jerk, but a genuine guy willing to help others. I hope the mis-understanding is cleared.

    You can continue posting your questions and we would be very happy guiding you. :)

    Goldest
    Java Is A Funny Language... Really!
    Click on * and add to member reputation, if you find their advices/solutions effective.

  20. #20
    Quizzle23 is offline Member
    Join Date
    Feb 2011
    Posts
    34
    Rep Power
    0

    Default

    Thanks for the info goldest. Can you answer my question?

    How would I divide 3 different items?
    For instance:

    If testDays needs to equal testWidgets / testHours / testProduction. How would it be formatted? I have tried everything in my book but it will not compile. Thanks in advance

Page 1 of 2 12 LastLast

Similar Threads

  1. The null message is driving me crazy
    By Yakg in forum New To Java
    Replies: 5
    Last Post: 12-02-2010, 07:03 PM
  2. image does not refresh-driving me crazy
    By jambon in forum AWT / Swing
    Replies: 1
    Last Post: 04-09-2010, 04:25 PM
  3. THIS PROGRAM IS DRIVING ME CRAZY!!! help fixing it
    By syntrax in forum New To Java
    Replies: 2
    Last Post: 12-18-2009, 04:27 AM
  4. Loop driving me loopy!!!!!
    By soc86 in forum New To Java
    Replies: 8
    Last Post: 01-16-2009, 01:00 AM
  5. Errors driving me crazy! although compiles fine
    By irishsea2828 in forum New To Java
    Replies: 1
    Last Post: 04-08-2008, 03:23 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •