2017-05-11 4 views
0

は、私はそれが私が機械に入れていることを去った私に私の選択とお金の量を伝えたい私の選択と変更の両方を印刷するにはどうしたらいいですか?

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 

答えて

関連する問題