2017-05-11 1 views
0

Ich will es mir meine Wahl sagen, und die Menge an Geld, das ich verlassen habe, dass ich in der Maschine setzteWie mache ich es drucken meine Auswahl und Änderung fällig?

Module Module1 

    Sub Main() 
     Dim moneyInserted As Double 
     Dim selectedSoda As String 
     Dim changedue As Double = 0.5 


     Console.WriteLine("Insert Money") 
     moneyInserted = Console.ReadLine() 
     Console.WriteLine("Type A for Crystal Clear Pepsi, B for New Coke, and C for OK Soda") 
     selectedSoda = Console.ReadLine() 
     Dim theSoda As String = sodaMachine(selectedSoda, moneyInserted, changedue) 
     Console.WriteLine("Your choice is {0}", sodaMachine(selectedSoda,moneyInserted, changedue)) 
     Console.ReadLine() 

    End Sub 

    Function sodaMachine(ByVal selection As String, ByVal money As Double, ByVal change As Double) As String 
     If money >= 0 Then 
      Return (money - change) 
      If selection = "A" Or selection = "a" Then 
       Return "Crystal Clear Pepsi" 

      ElseIf selection = "B" Or selection = "b" Then 
       Return "New Coke" 

      ElseIf selection = "C" Or selection = "c" Then 
       Return "OK Soda" 
      Else 
       Return "Invalid Selection" 
      End If 
     Else 
      Return "Not enough money" 
     End If 

    End Function 

End Module 

Antwort

Verwandte Themen