所述值尚未设定值

所述值尚未设定值

本文介绍了所述值尚未设定值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Module Module1

    Sub Main()
        Dim firstName As String
        Dim lastName As String
        Dim pointsReceived As Decimal
        Dim scorePercentage As Decimal
        Dim finalGrade As String

        Console.WriteLine("Welcome to the Stundent Grade Calculator. This program will calculate students score percentage and grade score.")
        Console.WriteLine("Please Enter students first name:")
        firstName = Console.ReadLine()
        Console.WriteLine("Please enter students last name:")
        lastName = Console.ReadLine()
        Console.WriteLine("Please enter students points received:")
        pointsReceived = Console.ReadLine()
        If pointsReceived >= 0 And pointsReceived <= 1000 Then
            Console.WriteLine("Good Score")
        Else
            Console.WriteLine("Error")
        End If

        scorePercentage = (pointsReceived / 1000) * 100
        If scorePercentage >= 0 And scorePercentage <= 59 Then
            finalGrade = "F"
            If scorePercentage >= 60 And scorePercentage <= 69 Then
                finalGrade = "D"
                If scorePercentage >= 70 And scorePercentage <= 79 Then
                    finalGrade = "C"
                    If scorePercentage >= 80 And scorePercentage <= 89 Then
                        finalGrade = "B"
                        If scorePercentage >= 90 And scorePercentage <= 100 Then
                            finalGrade = "A"
                        Else
                            Console.WriteLine("Error")
                        End If
                    End If
                End If
            End If
        End If
        Console.WriteLine("Student first name: " & firstName)
        Console.WriteLine("Students last name: " & lastName)
        Console.WriteLine("Students points: " & pointsReceived)
        Console.WriteLine("Calculated Percentage: %" & scorePercentage)
        Console.WriteLine("Final Grade: " & finalGrade)*/Problem is finalGrade 
        Console.ReadLine()

    End Sub

End Module

推荐答案

Dim firstName As String =""
Dim lastName As String =""
Dim pointsReceived As Decimal = 0
Dim scorePercentage As Decimal = 0
Dim finalGrade As String = "" ' this variable is not initialized with a value


Dim finalGrade As String = Nothing



这篇关于所述值尚未设定值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-23 12:44