The Worksheet named Grades contains a place for students to record the grades they have received in their classes. Students put the number of each letter grade received in the B column. (For example, the worksheet currently shows that the student has taken 9 classes and made five As, one B, one C, one D, and one F as grades. You need to write a program that reads the grades from the worksheet and uses a function to calculate the student’s GPA. For this problem you can assume that all classes are worth the same number of credit hours. The function should send back the GPA to the calling procedure. The procedure will then put up a message box that gives the student their GPA and a message about their GPA, all in one message box. The message should be “You qualify for an internship” if the student has a GPA of at least 3.0. It should be “You’re in the danger zone” if the GPA is between 2.0 and 3.0. And it should be “You are on probation.” if the GPA 2.0 or lower. The message box below is an example of what should be shown to the user. Do not worry about the formatting of the GPA, if yours has lots of decimal places, that is OK.

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter8: Arrays And Strings
Section: Chapter Questions
Problem 19PE
icon
Related questions
Question

Write VBA CODE FOR THE FOLLOWING PROBLEM

Problem:

  1. The Worksheet named Grades contains a place for students to record the grades they have received in their classes. Students put the number of each letter grade received in the B column.  (For example, the worksheet currently shows that the student has taken 9 classes and made five As, one B, one C, one D, and one F as grades.  You need to write a program that reads the grades from the worksheet and uses a function to calculate the student’s GPA.  For this problem you can assume that all classes are worth the same number of credit hours.  The function should send back the GPA to the calling procedure.  The procedure will then put up a message box that gives the student their GPA and a message about their GPA, all in one message box.  The message should be “You qualify for an internship” if the student has a GPA of at least 3.0.  It should be “You’re in the danger zone” if the GPA is between 2.0 and 3.0.  And it should be “You are on probation.” if the GPA 2.0 or lower.  The message box below is an example of what should be shown to the user.  Do not worry about the formatting of the GPA, if yours has lots of decimal places, that is OK.
Expert Solution
PROGRAM CODE

Sub showValue()
    Dim arr(9)
    For i = 0 To 8 Step 1
    arr(i) = Range("B" & (i + 2))
    Next
    Dim gpa As Double
    gpa = 0
    For i = 0 To 8 Step 1
        If arr(i) = "A" Then
        gpa = gpa + 10
        ElseIf arr(i) = "B" Then
        gpa = gpa + 9
        ElseIf arr(i) = "C" Then
        gpa = gpa + 8
        ElseIf arr(i) = "D" Then
        gpa = gpa + 7
        ElseIf arr(i) = "F" Then
        gpa = gpa + 5
        End If
    Next
    
        
        If gpa > 3 Then
        MsgBox "You qualify for an internship " & "GPA: " & gpa
        ElseIf gpa < 3 And gpa > 2 Then
        MsgBox "You’re in the danger zone " & "GPA: " & gpa
        ElseIf gpa < 2 Then
        MsgBox "GPA: " + gpa + "You are on probation. " & "GPA: " & gpa
        End If
End Sub

trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 3 images

Blurred answer
Knowledge Booster
Function Arguments
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,