Hello all I am looking for someone to walk me through how to build a change calculator in Visual Basic. I do not want someone to actually do the project for me, as this would be plagarism since I have to turn this in, but I do need help. I would be willing to pay 10 USD via PayPal if you would be willing to assist me tomorrow afternoon night, or saturday during the day. Please email me to arrange a time to work on it. I have all the buttons, labels and such setup, but have no idea where to start with the code and such, below is the directions to the project. Please email me at wheresmyhippo@gmail.com if you are interested.
CODE
You will put all of your code in the button's click even subroutine. The algorithm for the program is as follows:
1. Calculate the total change to give back (i.e. amount paid - amount owed)
2. Calculate the number of one dollar bill to hand back
3. Adjust the change amount by subtracting the dollar amount handed back
4. Calculate the number of quarters to hand back based on the new change amount
5. Adjust the change amount by subtracting the quarter amount handed back
6. Calculate the number of dimes to hand back based on the new change amount
7. Adjust the change amount by subtracting the dimes amount handed back
8. Calculate the number of nickels to hand back based on the new change amount
9. Adjust the change amount by subtracting the nickels amount handed back
10. Calculate the number of pennies to hand back based on the new change amount
The total change to give back is just the amount paid minus the amount owed. In the example, the total change is 40.37 (i.e. 400 - 359.63).
To calculate the number of one dollar bill to hand back, you need to divide the change amount by the value of a dollar. In this case, the value of a dollar is 1, so you don't need to actually do any division (dividing something by 1 doesn't change its value). However, you need to extract the whole number part of the change amount to get the number of one dollar bill to hand back. To do this, you need to use the built in function Math.Floor( ) in Visual Basic. The Math.Floor( ) function accepts a number and rounds off the number to its lowest integer value. For example, Math.Floor(1.9) gives 1, Math.Floor(1.2) gives 1, Math.Floor(1.5) gives 1, and Math.Floor(40.37) gives 40.
After calculating the number of one dollar bill to hand back, you need to adjust the change amount by subtracting the dollar amount handed back. The dollar amount is just equal to the number of one dollar bill handed back. In the example, the adjusted change amount is 0.37 (i.e. 40.37 - 40).
To calculate the number of quarters to hand back, you can repeat the process above. Divide the adjusted change amount by the value of a quarter and apply the Math.Floor( ) function to the result. For example, 0.37 divided by 0.25 is equal to 1.48. Math.Floor(1.48) gives 1 (this is the number of quarters to hand back). After calculating the number of quarters to hand back, adjust the change amount by subtracting the quarters amount handed back. The quarters amount is just equal to the number of quarters handed back multiplied by the value of a quarter. Using the example above, the quarters amount is 1 times 0.25 which is equal to 0.25. So you need to subtract 0.25 from 0.37 to get the adjusted change amount which is 0.12.
Repeat the above steps to calculate the number of dimes, nickels, and pennies to hand back.
Technical Details:
Put the line of code Option Strict On at the top of your program code. This line of code will prevent you from assigning variables of different types to one another.
Declare local variables of type double for amount owed, amount paid, change amount, dollars amount, quarters amount, and so on.
Declare local variables of type integer for the number of dollars to hand back, the number of quarters to hand back, the number of dimes to hand back, and so on.
You may also want to declare constants to hold the values of each type of bill or coinage. For example, Const dblQuarter As Double = 0.25
When assigning the value of a textbox's text property to a double variable, you can use either the Val( ) function or the CDbl( ) function. For example, dblAmountOwed = Val(txtAmountOwed.Text) or dblAmountOwed = CDbl(txtAmountOwed.Text) convert the string value indicated by the Text property of txtAmountOwed to a double value and assign it to the double variable dblAmount Owed.
When assigning the value of a double variable to a label's text property, you need to use the .ToString method of the double variable in order to convert the double value to a string value. For example, lblChangeAmount.Text = dblChangeAmount.ToString converts the double value of the variable dblChangeAmount to a string value and assigns it to the Text property of label lblChangeAmount.
If the number of pennies your program calculates to hand back is off by one, its OK. This is only true for the pennies.
You must comment the code that you have written (not the automatically generated stuff.) Remember that comments begin with a ' and state what you are doing in each section in simple English.
1. Calculate the total change to give back (i.e. amount paid - amount owed)
2. Calculate the number of one dollar bill to hand back
3. Adjust the change amount by subtracting the dollar amount handed back
4. Calculate the number of quarters to hand back based on the new change amount
5. Adjust the change amount by subtracting the quarter amount handed back
6. Calculate the number of dimes to hand back based on the new change amount
7. Adjust the change amount by subtracting the dimes amount handed back
8. Calculate the number of nickels to hand back based on the new change amount
9. Adjust the change amount by subtracting the nickels amount handed back
10. Calculate the number of pennies to hand back based on the new change amount
The total change to give back is just the amount paid minus the amount owed. In the example, the total change is 40.37 (i.e. 400 - 359.63).
To calculate the number of one dollar bill to hand back, you need to divide the change amount by the value of a dollar. In this case, the value of a dollar is 1, so you don't need to actually do any division (dividing something by 1 doesn't change its value). However, you need to extract the whole number part of the change amount to get the number of one dollar bill to hand back. To do this, you need to use the built in function Math.Floor( ) in Visual Basic. The Math.Floor( ) function accepts a number and rounds off the number to its lowest integer value. For example, Math.Floor(1.9) gives 1, Math.Floor(1.2) gives 1, Math.Floor(1.5) gives 1, and Math.Floor(40.37) gives 40.
After calculating the number of one dollar bill to hand back, you need to adjust the change amount by subtracting the dollar amount handed back. The dollar amount is just equal to the number of one dollar bill handed back. In the example, the adjusted change amount is 0.37 (i.e. 40.37 - 40).
To calculate the number of quarters to hand back, you can repeat the process above. Divide the adjusted change amount by the value of a quarter and apply the Math.Floor( ) function to the result. For example, 0.37 divided by 0.25 is equal to 1.48. Math.Floor(1.48) gives 1 (this is the number of quarters to hand back). After calculating the number of quarters to hand back, adjust the change amount by subtracting the quarters amount handed back. The quarters amount is just equal to the number of quarters handed back multiplied by the value of a quarter. Using the example above, the quarters amount is 1 times 0.25 which is equal to 0.25. So you need to subtract 0.25 from 0.37 to get the adjusted change amount which is 0.12.
Repeat the above steps to calculate the number of dimes, nickels, and pennies to hand back.
Technical Details:
Put the line of code Option Strict On at the top of your program code. This line of code will prevent you from assigning variables of different types to one another.
Declare local variables of type double for amount owed, amount paid, change amount, dollars amount, quarters amount, and so on.
Declare local variables of type integer for the number of dollars to hand back, the number of quarters to hand back, the number of dimes to hand back, and so on.
You may also want to declare constants to hold the values of each type of bill or coinage. For example, Const dblQuarter As Double = 0.25
When assigning the value of a textbox's text property to a double variable, you can use either the Val( ) function or the CDbl( ) function. For example, dblAmountOwed = Val(txtAmountOwed.Text) or dblAmountOwed = CDbl(txtAmountOwed.Text) convert the string value indicated by the Text property of txtAmountOwed to a double value and assign it to the double variable dblAmount Owed.
When assigning the value of a double variable to a label's text property, you need to use the .ToString method of the double variable in order to convert the double value to a string value. For example, lblChangeAmount.Text = dblChangeAmount.ToString converts the double value of the variable dblChangeAmount to a string value and assigns it to the Text property of label lblChangeAmount.
If the number of pennies your program calculates to hand back is off by one, its OK. This is only true for the pennies.
You must comment the code that you have written (not the automatically generated stuff.) Remember that comments begin with a ' and state what you are doing in each section in simple English.
