VB.NET newbie problem 2 - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

VB.NET newbie problem 2

TerabojinTerabojin Posts: 1Member
Similar to a previous problem using trailer record logic that was posted I am also struggling to get my code to work. I am supposed to output the customers name and how much their change is, item cost, number of quarters, dimes, nickles, and pennies.

This is the code that I have so far, please help me?

Sub Main()

' variables for storing user input
Dim cname As String
Dim itemcost As Decimal

' variables for storing cosole output
Dim change As Double
Dim tempchange As Double
Dim count1 As Integer = 0
Dim count2 As Integer = 0
Dim count3 As Integer = 0
Dim count4 As Integer = 0
change = tempchange
tempchange = 0

' get input from user
Console.WriteLine("Please enter the Customer(s) name ")
Console.WriteLine("Please enter the itemcost ")
cname = Console.ReadLine()
itemcost = Console.ReadLine()

'converting change due from item cost
If itemcost <= 0 Then
Write("No Input ")
Console.WriteLine("Press enter to continue.")
Do While itemcost > 0
change = 1 - itemcost

Do While tempchange >= 0.25
tempchange = tempchange - 0.25
count1 = count1 + 1

Do While tempchange >= 0.1
tempchange = tempchange - 0.1
count2 = count2 + 1

Do While tempchange >= 0.05
tempchange = tempchange - 0.05
count3 = count3 + 1

Do While tempchange >= 0.01
tempchange = tempchange - 0.01
count4 = count4 + 1

' display results
Console.WriteLine("The customer's name is")
Console.WriteLine("The itemcost is")
Console.WriteLine("The change is")
Console.WriteLine("Quarter(s) {0}", count1)
Console.WriteLine("Dime(s) {1}", count2)
Console.WriteLine("Nickle(s) {2}", count3)
Console.WriteLine("Penny(s) {3}", count4)

'prevents window from closing

End If
End Sub

End Module

Sign In or Register to comment.