Results 1 to 7 of 7
  1. #1
    shin777 is offline Member
    Join Date
    May 2013
    Posts
    43
    Rep Power
    0

    Default Totally new to java, going through some text book programming challenge. need help.

    Attachment 5054
    I am using jgraps and don't know how I have to start with this problem on my book. This is as far as I could do from what I learned from book. :(

    It says

    Last month Joe purchased some stock in Acme software, Inc. Here are the details of the purchase:

    -the number of shares that Joe purchased was 1,000
    -When Joe purchased stock, he paid $32.87 per share
    -Joe paid his stockbroker a commission that amounted to 2% of the amount he paid for the stock.

    Two weeks later Joe sold the stock. Here are the details of the sale:
    -the number of shares that joe sold was 1,000
    -He sold the stock for $33.92 per share.
    -He paid his stockbroker another commission that amounted to 2% of the amount he received for the stock.

    Write a program that displays the following information:
    -the amount of money Joe paid for the stock.
    -the amount of commission Joe paid his broker when he bought the stock.
    -the amount that Joe sold the stock for.
    -the amount of commission Joe paid his broker when he sold the stock.
    -display the amount of profit that Joe made after selling his stock and paying the two commissions to his broker.
    (if the amount of profit that your program displays is a negative number, then Joe lost money on the transaction.)


    I read through books but it doesn't give me any similar examples and helps aren't available to me
    coz no one I know around me know anything about java. there are bunch of other program challenge problems
    I want to try but no matter how many times I read books, books doesn't explain much about how to write them
    or have solution list. I am using starting out with java from control structures through objects 5th edition from Tony Gaddis.
    Is there solution lists available somewhere online for this book's programming challenge? I can do all example problems
    but like the math books, exercise problems are several steps harder than example problems and they don't explain
    how to do it either. How do these book makers expect anyone new to book do these problems by their own unless
    they have tutor or something? :(
    Attached Thumbnails Attached Thumbnails Totally new to java, going through some text book programming challenge. need help.-untitled.jpg  
    Last edited by shin777; 05-28-2013 at 03:59 AM.

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

    Default Re: Totally new to java, going through some text book programming challenge. need hel

    As far as I can see this is a math problem and not that difficult to do in any programming language. All you need to do is declare a bunch of variables, do some calculations and assign the result to the variables. Then display results on screen. What specific problems are you having?

  3. #3
    shin777 is offline Member
    Join Date
    May 2013
    Posts
    43
    Rep Power
    0

    Default Re: Totally new to java, going through some text book programming challenge. need hel

    thank you. can you show me some example or something? i can do math with my head but don't know how to write it in java. I am at ch.2 of book and it doesn't really show me how to do it or have examples. :(
    I probably read it through 3 times by now.

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

    Default Re: Totally new to java, going through some text book programming challenge. need hel

    Doing it in java is pretty much the same.
    Java Code:
    int a = 5;
    int b = 10;
    int c = a * b;
    int d = b - a + 20;
    int e = b - (a + 20);
    //etc

  5. #5
    shin777 is offline Member
    Join Date
    May 2013
    Posts
    43
    Rep Power
    0

    Default Re: Totally new to java, going through some text book programming challenge. need hel

    Ok. thank you. I rewrote it. Does it look ok now? :)

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

    Default Re: Totally new to java, going through some text book programming challenge. need hel

    I don't know. Sorry to be harsh but it is not my job to make sure your code works, it is yours. Does it produce the correct result?

  7. #7
    shin777 is offline Member
    Join Date
    May 2013
    Posts
    43
    Rep Power
    0

    Default Re: Totally new to java, going through some text book programming challenge. need hel

    It runs and I don't get error. It produces correct result too. I was just asking if it looked ok to you. I understand it's not your job to check my answers. Thank you for your help anyway. :)

Similar Threads

  1. Replies: 1
    Last Post: 07-14-2012, 10:57 AM
  2. programming challenge - calculator display
    By weps in forum Advanced Java
    Replies: 8
    Last Post: 09-16-2011, 09:47 PM
  3. java programming challenge Number 1
    By tacosalad in forum New To Java
    Replies: 5
    Last Post: 01-16-2008, 10:25 PM
  4. Programming an Address book
    By d.anthonii in forum New To Java
    Replies: 0
    Last Post: 12-31-2007, 05:26 PM
  5. Replies: 1
    Last Post: 08-07-2007, 05:19 AM

Posting Permissions

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