Link to home
Start Free TrialLog in
Avatar of IchigoMD
IchigoMD

asked on

VB.Net Console Application

I am trying to create a console application that will take an inputted dollar amount and tell you how much of each item you can by for that amount. like this example:

 Enter dollar amount: $10
You can buy any one of the following items with $10.

22.7273 pounds of Bananas
10.101 pounds of Apples
8.4034 pounds of Cucumbers
11.236 pounds of Carrots
12.6582 pounds of Oranges

Do you want to try for another amount? ...

Here is what I have so far.

Open in new window

'Project:       How Much Can I Buy Console App


    Private promptMessage As String = "Enter a dollar amount"
    Private welcomeMessage As String = " Welcome to How Much Can I Buy"


    Sub Main()

        Dim strInput As String
        Dim DollarAmt As Double = 0
        Dim ProductPrice As Double
        Dim ProductAmt As Double
        Dim ProductName As String

        Console.WriteLine(welcomeMessage)
        Console.WriteLine(promptMessage)

    ProductPrice = _{{0.44, 0.99, 1.19, 0.89, 0.79}}
        'ProductName =_ {{Bananas, Apples, Cucumbers, Carrots, Oranges}}
    While
            ProductAmt = DollarAmt / ProductPrice

    then print strInput

            If


                Console.WriteLine("You can buy any one of the following items with" & DollarAmt)
                strInput = Console.ReadLine()
        case bananas
                Console.WriteLine(ProductAmt & "pounds of Bananas")
        case apples
                Console.WriteLine(ProductAmt & "pounds of Apples")
        case cucumbers
                Console.WriteLine(ProductAmt & "pounds of Cucumbers")
        case carrots
                Console.WriteLine(ProductAmt & "pounds of Carrots")
        case oranges
                Console.WriteLine(ProductAmt & "pounds of Oranges")
End Module

Open in new window

Avatar of Tom Beck
Tom Beck
Flag of United States of America image

Your code seems overly complicated. Why the rectangular arrays? Why the "case"? Is this a student assignment?
Avatar of IchigoMD
IchigoMD

ASKER

Yes I have trouble starting but once i know how to get it started i think I know the correct direction to go.
ASKER CERTIFIED SOLUTION
Avatar of Tom Beck
Tom Beck
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial