PDA

View Full Version : School project help..



Five Oh Six
10-12-2010, 02:58 PM
I've been trying to figure the code out for over a week now and I have no idea what to write.. If you could help me it would be very appreciated.. :/

Here is the assignment:

Create a money changer application that displays the number of quarters, dimes, nickels and pennies necessary to make up the amount of change entered by the user. Ask the user to enter the amount of change as an integer value.

You may use a graphic if you wish. The application interface will look similar to the following:

http://img299.imageshack.us/img299/7793/werfewrf.png

I need a code so when you click the "calculate" button the number of cents inputed in the "92" text box will equal the pennies, dimes, nickels and quarters added up to the total amount of cents.. :/

FreshPrince
10-12-2010, 03:34 PM
DeHaterZ and VisualBasic know pretty much about visualbasic, try asking them.

DarK
10-12-2010, 09:29 PM
did you do your General declarations yet?

Dim intPennies as Integer
Dim intQuarters as Integer
Dim intNickles as Integer
Dim intDimes as Integer

Five Oh Six
10-12-2010, 09:30 PM
No sir, I have no idea where to start.. :/

Dxt-FlyChick
10-12-2010, 09:45 PM
you came this far
did you google, how to do what you need done?
maybe a IT guru posted it

smutherr
10-12-2010, 09:47 PM
Logic for calculation using java or c level syntax and declaration

let user input value in (variable x of type double):
double x;

Divide x by quarter (0.25) and store the result in integer variable quarter:
int quarter = int(x/0.25);

Then change the value of x to (x - (0.25 * quarter):
x = (x - (0.25 * quarter);

Then divide the new obtained value of x by 0.10 and store it in dime of int type:
int dime = int(x/0.10);

Change the value of x again:
x = (x -(0.10 * dime);

Then divide the new obtained value of x by 0.05 and store it in nickel of int type:
int nickel = int(x/0.05);

Change the value of x again:
x = (x -(0.05 * nickel);

Then divide the new obtained value of x by 0.01 and store it in pennies of int type:
int pennies = int(x/0.01);

combined code should look like this in c or java:

double x;
int quarter = int(x/0.25);
x = (x - (0.25 * quarter);
int dime = int(x/0.10);
x = (x -(0.10 * dime);
int nickel = int(x/0.05);
x = (x -(0.05 * nickel);
int pennies = int(x/0.01);

Now in your gui link quarters to quarters, dimes to dimes and nickel to nickels and so on. Let me know if this helps

DarK
10-12-2010, 09:52 PM
intPennies = Val(txtPennies.Text)

'Calculate and display number of Quarters'
intQuarters = intPennies / 25
intPennies = intPennies Mod 25
lblQuarters.Caption = intQuarters

'Calculate and display number of Dimes'
intDimes = intPennies / 10
intPennies = intPennies Mod 10
lblDimes.Caption = intDimes

'Calculate and display number of Nickles'
intNickles = intPennies / 5
intPennies = intPennies Mod 5
lblNickles.Caption = intNickles

'Calculate and display number of Pennies'
intPennies = intPennies / 1
intPennies = intPennies Mod 1
lblPennies = intPennies

'Calculate Customer Cost'
lblCost.Caption
End Sub

it's not done my program is a kind of "Coin star" machine I am doing the customer cost now

and remember your General Declarations

Dim intPennies as Integer
Dim intQuarters as Integer
Dim intDimes as Integer
Dim intNickles as Integer

Five Oh Six
10-16-2010, 09:59 PM
Thanks everyone for the help but I got it figured out and it was alot easier than I expected