none
Get Marks Out of Hundred RRS feed

  • Question

  • Please consider these cases -

    a) Lets say we got 55 Marks Out of 100 Marks
    b) We got 45 Marks Out of 80 Marks

    In Case B, we got 45 Marks out of 80 Marks, I am using the following Code to convert the Marks Obtained Out of Hundred -

    Dim CalculateMarks As Decimal = MarksObtained * 100 / TotalMarks
    What If we get 70 Marks Out of 150 Marks, how can we get the Marks Obtained out of Hundred, Can someone help ?

    Friday, October 6, 2017 12:47 PM

Answers

  • Please consider these cases -

    a) Lets say we got 55 Marks Out of 100 Marks
    b) We got 45 Marks Out of 80 Marks

    In Case B, we got 45 Marks out of 80 Marks, I am using the following Code to convert the Marks Obtained Out of Hundred -

    Dim CalculateMarks As Decimal = MarksObtained * 100 / TotalMarks
    What If we get 70 Marks Out of 150 Marks, how can we get the Marks Obtained out of Hundred, Can someone help ?

    If I understand correctly...

            Dim marks As Decimal = 55D
            Dim totmarks As Decimal = 100D
            Dim percent As Decimal = marks / totmarks
            Dim marks100 As Decimal = percent * 100D
    
            marks = 45D
            totmarks = 80D
            percent = marks / totmarks
            marks100 = percent * 100D
    
            marks = 70D
            totmarks = 150D
            percent = marks / totmarks
            marks100 = percent * 100D
    


    "Those who use Application.DoEvents() have no idea what it does and those who know what it does never use it." - MSDN User JohnWein    Multics - An OS ahead of its time.

    • Marked as answer by Sid Williams Friday, October 6, 2017 1:54 PM
    Friday, October 6, 2017 12:57 PM

All replies

  • Please consider these cases -

    a) Lets say we got 55 Marks Out of 100 Marks
    b) We got 45 Marks Out of 80 Marks

    In Case B, we got 45 Marks out of 80 Marks, I am using the following Code to convert the Marks Obtained Out of Hundred -

    Dim CalculateMarks As Decimal = MarksObtained * 100 / TotalMarks
    What If we get 70 Marks Out of 150 Marks, how can we get the Marks Obtained out of Hundred, Can someone help ?

    If I understand correctly...

            Dim marks As Decimal = 55D
            Dim totmarks As Decimal = 100D
            Dim percent As Decimal = marks / totmarks
            Dim marks100 As Decimal = percent * 100D
    
            marks = 45D
            totmarks = 80D
            percent = marks / totmarks
            marks100 = percent * 100D
    
            marks = 70D
            totmarks = 150D
            percent = marks / totmarks
            marks100 = percent * 100D
    


    "Those who use Application.DoEvents() have no idea what it does and those who know what it does never use it." - MSDN User JohnWein    Multics - An OS ahead of its time.

    • Marked as answer by Sid Williams Friday, October 6, 2017 1:54 PM
    Friday, October 6, 2017 12:57 PM
  • Thanks a lot.
    Friday, October 6, 2017 1:54 PM