1. Member Join Date
Jan 2013
Posts
4
Rep Power
0

## [Help] About changing computing program (Java)

Guys, i need help about something in Java. Im a newbie and i don't know nothing about it so i need u're help 'cuz i need that for a seminar paper.

I have to change computing program to programming projects, u can see an example down there:

1. Set the starting value of money.
2. Subtract the maximum number of quarters from money, and print the quantity
of quarters extracted.
3. Subtract the maximum number of dimes from money, and print the quantity of
dimes extracted.
4. Subtract the maximum number of nickels from money, and print the quantity of
nickels extracted.
5. The remainder of money is printed as pennies.
Here is how we might write the ¯rst step in Java:
int dollars = 3;
int cents = 46;
int money = (dollars * 100) + cents;
The second step of the algorithm is cleverly written as follows:
System.out.println("quarters = " + (money / 25));
money = money % 25;
These statements exploit integer division, /, and integer modulo, %.
In the ¯rst statement, money / 25 calculates the maximum number of quarters to
extract from money. There are two important points:
1. The integer division operator, /, calculates integer quotient|the number of
times 25 can be subtracted from money without leaving a negative remainder. In
the example, since money's cell holds 346, the quotient is 13, because a maximum
of 13 quarters (13*25 = 325) can be wholly subtracted from 346 without leaving
a negative remainder. Here are additional examples for intuition:
² 14 / 3 computes to 4 (and the remainder, 2, is forgotten)
² 6 / 3 computes to 2 (and there is no remainder)
² 4 / 5 computes to 0, because 5 cannot be wholly subtracted from 4
2. The calculation of the division, money / 25, does not alter the value in money's
cell, which remains 346|only an assignment statement can change the value in
money's cell.
The second statement, money = money % 25, deals with the second point just men-
tioned: Since we have calculated and printed that 13 whole quarters can be extracted
from the amount of money, we must reset the value in money's cell to the remainder.
This can be done either of two ways:

1. By the statement,
money = money - ((money / 25) * 25);
which calculates the monetary value of the extracted quarters and subtracts
this from money.
2. By the more elegant statement,
money = money % 25;
whose modulo operator, %, calculates the integer remainder of dividing money
by 25 and assigns it to money. In this example, the remainder from performing
346/25 is of course 21. Here are additional examples of computing remainders:
² 14 % 3 computes to 2
² 6 % 3 computes to 0
² 4 % 5 computes to 4
The combination of the integer quotient and remainder operations calculates the
correct quantity of quarters.

Java Code:
```/** MakeChange calculates the change for the amounts in variables
* dollars and cents. */
public class MakeChange
f public static void main(String[] args)
f int dollars = 3;
int cents = 46;
int money = (dollars * 100) + cents;
System.out.println("quarters = " + (money / 25));
money = money % 25;
System.out.println("dimes = " + (money / 10));
money = money % 10;
System.out.println("nickels = " + (money / 5));
money = money % 5;
System.out.println("pennies = " + money);
}
}```

So, the semniar paper is this: Rebuild the change-making program, so that it uses a
model that is this specification (watch the photo below): Last edited by Ghack; 01-04-2013 at 09:21 PM. 2. ## Re: [Help] About changing computing program (Java)

I see no image in your post above and no specific answerable question. What exactly do you need help with? The more specific your question, usually the better our answers will be. 3. ## Re: [Help] About changing computing program (Java) 4. Member Join Date
Jan 2013
Posts
4
Rep Power
0

## Re: [Help] About changing computing program (Java)

There is the photo, look at it 5. ## Re: [Help] About changing computing program (Java) 6. Member Join Date
Jan 2013
Posts
4
Rep Power
0

## Re: [Help] About changing computing program (Java)

See that thing up there :/ 7. ## Re: [Help] About changing computing program (Java) 8. Member Join Date
Dec 2012
Posts
42
Rep Power
0

## Re: [Help] About changing computing program (Java)

It sounds like your asking the people here to do your homework for you? unfortunatly thats not how it works, if your having trouble with a specific part of your homework and you have a legitimate question the people here are more than happy to help. First you have to try and do this on your own, and then ask questions about specific probems your having, otherwise you will not find much help here. 9. Member Join Date
Jan 2013
Posts
4
Rep Power
0

## Re: [Help] About changing computing program (Java) Originally Posted by Russd772 It sounds like your asking the people here to do your homework for you? unfortunatly thats not how it works, if your having trouble with a specific part of your homework and you have a legitimate question the people here are more than happy to help. First you have to try and do this on your own, and then ask questions about specific probems your having, otherwise you will not find much help here.
I tryed but all of that was a horrible mistake, i told u that i'm really a newbie in this things and i do not know nothing about this, for that i ask u that question. 10. ## Re: [Help] About changing computing program (Java) Originally Posted by Ghack I tryed but all of that was a horrible mistake, i told u that i'm really a newbie in this things and i do not know nothing about this, for that i ask u that question.
You still haven't asked a question. Please know that no one is going to do your work for you. If you've tried a solution and it's not working, then please by all means show your code, show your errors, and ask your questions. If all you want is for someone to solve this for you, then please go elsewhere (though you'll likely get the same response on any programming forum). 11. ## Re: [Help] About changing computing program (Java) Originally Posted by Ghack Assuming that the double negative wasn't intended, here's where you can change that: The Java Tutorials

Now, since this thread is going nowhere rather rapidly, I'm closing it. Feel free to start another thread when you can ask an answerable question on the lines of this web page: How to ask questions the smart way

db 