Using Visual Basic: Create a program in Visual Basic that will allow the user to
ID: 3576343 • Letter: U
Question
Using Visual Basic:
Create a program in Visual Basic that will allow the user to enter in any whole # and have the program figure out how many dollars, quarters, dimes, nickels and pennies there are. The program will first calculate the amount of dollars and with the left over change it will calculate the amount of quarters. With the left over change from the quarters it will calculate the amount of dimes, then nickels and if any leftover will be pennies.
Follow all naming conventions that we talked about in class when writing your code. Add a picture that would be appropriate for the program. Have a button that displays the output and a clear button to clear any text boxes or labels. Make sure you add comments to your program with your name. Use the Integer division () and the MOD function. Use dimension statements. Define your constants as below:
Dollars …………………….100
Quarters…………………..25
Dimes……………………….10
Nickels……………………….5
Your output should look like this for the number 364
Dollars 3
Quarters 2
Dimes 1
Nickels 0
Pennies 4
Explanation / Answer
VERSION 5.00
Begin VB.Form Form1
BorderStyle = 4 'Fixed ToolWindow
Caption = " Converter"
ClientHeight = 1815
ClientLeft = 45
ClientTop = 285
ClientWidth = 2040
ForeColor = &H00000000&
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 1815
ScaleWidth = 2040
StartUpPosition = 2 'CenterScreen
Begin VB.TextBox Text1
BackColor = &H00C0C0C0&
Height = 285
Left = 120
Locked = -1 'True
TabIndex = 1
Top = 120
Width = 1815
End
Begin VB.CommandButton Command1
Caption = "convert"
Height = 255
Left = 1320
TabIndex = 2
Top = 1440
Width = 615
End
Begin VB.CommandButton Command2
Caption = "clear"
Height = 255
Left = 1320
TabIndex = 3
Top = 1440
Width = 615
End
Begin VB.Label dollar
BackColor = &H00C0C0C0&
Caption = "Dollar"
Height = 285
Left = 120
Locked = -1 'True
TabIndex = 4
Top = 120
Width = 1615
End
Begin VB.Label dlbl
BackColor = &H00C0C0C0&
Height = 285
Left = 120
Locked = -1 'True
TabIndex = 5
Top = 120
Width = 615
End
Begin VB.Label quarter
BackColor = &H00C0C0C0&
Caption = "Quarter"
Height = 285
Left = 120
Locked = -1 'True
TabIndex = 6
Top = 120
Width = 1615
End
Begin VB.Label quarlbl
BackColor = &H00C0C0C0&
Height = 285
Left = 120
Locked = -1 'True
TabIndex = 7
Top = 120
Width = 615
End
Begin VB.Label dimes
BackColor = &H00C0C0C0&
Caption = "Dimes"
Height = 285
Left = 120
Locked = -1 'True
TabIndex = 8
Top = 120
Width = 1615
End
Begin VB.Label dimlbl
BackColor = &H00C0C0C0&
Height = 285
Left = 120
Locked = -1 'True
TabIndex = 9
Top = 120
Width = 615
End
Begin VB.Label nickel
BackColor = &H00C0C0C0&
Caption = "Nickels"
Height = 285
Left = 120
Locked = -1 'True
TabIndex = 10
Top = 120
Width = 1615
End
Begin VB.Label niclbl
BackColor = &H00C0C0C0&
Height = 285
Left = 120
Locked = -1 'True
TabIndex = 11
Top = 120
Width = 615
End
Begin VB.Label pennies
BackColor = &H00C0C0C0&
Caption = "Pennies"
Height = 285
Left = 120
Locked = -1 'True
TabIndex = 12
Top = 120
Width = 1615
End
Begin VB.Label penlbl
BackColor = &H00C0C0C0&
Height = 285
Left = 120
Locked = -1 'True
TabIndex = 13
Top = 120
Width = 615
End
END
'when convert button is pressed
Private Sub Command1_Click()
Dim dollar,quarter,nickels,dimes,pennies,temp As Integer
temp = Val(Text1.Text)
dollar=temp/100 'convert to dollar
dlbl.Text=dollar 'set value into the label
temp=temp%100
quarter=temp/25 'convert to quarter
quarlbl.Text=quarter 'set value into the label
temp=temp%25
dimes=temp/10 'convert to dimes
dimlbl.Text=dimes 'set value into the label
temp=temp%10
nickels=temp/5 'convert to nickel
niclbl.Text=nickels 'set value into the label
temp=temp%5
pennies=temp 'remaining are pennies
penlbl.Text=pennies 'set value into the label
End Sub
'when clear button is clicked
Private Sub Command2_Click()
Text1.Text=""
End Sub
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.