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

1. Member
Join Date
May 2013
Posts
43
Rep Power
0

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? :(
Last edited by shin777; 05-28-2013 at 04:59 AM.

2. 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. Member
Join Date
May 2013
Posts
43
Rep Power
0

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. 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. Member
Join Date
May 2013
Posts
43
Rep Power
0

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. 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. Member
Join Date
May 2013
Posts
43
Rep Power
0

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. :)

Posting Permissions

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