ElseIf声明

时间:2017-11-23 20:11:29

标签: vb.net

我想问一下如何根据我给出的任务做到这一点,我试过但它没有真正起作用,任何人都可以告诉我为什么?如果你能告诉我正确的版本,那就更好了

任务是: 调整程序,以便用户必须为每颗钻石输入质量 - 每颗钻石的质量都是1(低质量)和5(高质量)之间的整数。 这是代码(对不起,如果它不好我是VB的新手) 任何人都可以告诉我如何修复,我被告知错误,但老实说,我不知道如何实际修复它们。 :(

Dim Weight As Integer
    Dim userValue As Boolean = True
    Dim diamonds As Integer = 0
    Console.WriteLine("Enter the weight of your diamond in grams")
    Weight = Console.ReadLine
    Dim Quality As Integer
    Dim DiamondPrice As Integer
    Console.WriteLine("Enter the quality of your diamond from 1 (low quality) to 5 (high quality)")
    Quality = Console.ReadLine
    If Quality = "1" Then
        DiamondPrice = "100"
    ElseIf Quality = "2" Then
        DiamondPrice = "150"
    ElseIf Quality = "3" Then
        DiamondPrice = "200"
    ElseIf Quality = "4" Then
        DiamondPrice = "250"
    ElseIf Quality = "5" Then
        DiamondPrice = "300"
    End If
    Console.ReadLine()
    Console.WriteLine("This diamond costs : " & Quality * )
    Console.WriteLine("Would you like to price another Y/N?")
    Console.ReadLine()
    While userValue
        Console.WriteLine("Enter the weight of the new diamond in grams")
        Weight = Console.ReadLine
        Console.WriteLine("This diamond costs : " & Weight * 350)
        Console.WriteLine("Would you like to price another Y/N?")
        userValue = Console.ReadLine.ToUpper().Trim() = "Y"
        diamonds += 1
    End While
    Console.WriteLine("The total number of diamonds entered is : {0}", diamonds)
    Console.ReadLine()

0 个答案:

没有答案