Question

Task: You want to calculate a student's GPA for a number of classes taken by the...

Task: You want to calculate a student's GPA for a number of classes taken by the student during a single semester. (In C# (C sharp))

Inputs: 1. the student's name

2. Class names for the classes taken by the student

3. Class letter grade for the classes taken by the student

4. Class credit hours for the classes taken by the student

Processing: 1. Accept and process classes until the user indicates they are finished

2. accumulate the number of credit hours taken by the student

3. Calculate the total number of "points" earned by the student as:

(a) For each class calculate the points by multiplying the credit hours for that class times the numeric equivalent of the letter grade. ( A=4.0 B=3.0 C=2.0 D=1.0 F=0)

(b) Total all points for all classes

4. Calculate the GPA as the total number of "points" divided by the total credit hours.

Output: Display a nicely worded message that includes the student's name and the GPA (decimal point number with 2 decimal places) achieved by the student that semester.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

using System;

public class Test
{
   public static void Main()
   {
       Console.WriteLine("Enter student name");
       string name = Console.ReadLine();
       double grade = 0;
       double totalCreditHours = 0;
       double points = 0;
       string className =" ";
       char letterGrade = 'G';
     
       do
       {
           Console.WriteLine("Enter the class name, letter grade for the class and credit hours <enter stop to end>");
            className = Console.ReadLine();
           if(className == "stop")//exit the do while loop if stop is entered
           break;
         
           letterGrade = Convert.ToChar(Console.ReadLine());
           double creditHours = Convert.ToDouble(Console.ReadLine());
           switch(letterGrade)
           {
               case 'A' : grade = 4.0;
                            break;
               case 'B' : grade = 3.0;
                            break;
               case 'C' : grade = 2.0;
                            break;
               case 'D' : grade = 1.0;
                            break;
               case 'F' : grade = 0.0;
                            break;
               default : Console.WriteLine("Invalid Grade");
                        break;
           }
         
           points = points + creditHours*grade;
           totalCreditHours = totalCreditHours + creditHours;
         
       }while(className != "stop");
     
       decimal GPA = Convert.ToDecimal(string.Format("{0:0.00}", points/totalCreditHours));//format GPA tp 2 decimal places
       Console.WriteLine(name + " has got "+ GPA +" GPA .");
     
    }
}


Output:

Enter student name Nancy Williams

Enter the class name, letter grade for the class and credit hours <enter stop to end>

Computer Networks

B

40

Enter the class name, letter grade for the class and credit hours <enter stop to end>

C#

B

35

Enter the class name, letter grade for the class and credit hours <enter stop to end>

Maths

A

25

Enter the class name, letter grade for the class and credit hours <enter stop to end> stop

Nancy Williams has got 3.25 GPA .

Add a comment
Know the answer?
Add Answer to:
Task: You want to calculate a student's GPA for a number of classes taken by the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • You will create a class to store information about a student�s courses and calculate their GPA....

    You will create a class to store information about a student�s courses and calculate their GPA. Your GPA is based on the class credits and your grade. Each letter grade is assigned a point value: A = 4 points B = 3 points C = 2 points D = 1 point An A in a 3 unit class is equivalent to 12 grade points (4 for the A times 3 unit class) A C in a 4 unit class is...

  • Create a GPA calculator in Java. Ask the end user for the credit hours and letter...

    Create a GPA calculator in Java. Ask the end user for the credit hours and letter grade for each class. Once the user is finished with the data entry, calculate and output the overall GPA for the given input. For example, if four classes are input, each of which is a three-hour course, with grades of A, B, B, and B, the overall GPA will be 3.25. The exact user interaction is up to you. As long as the requirements...

  • C++ Program classes READ THE FOLLOWING CAREFULLY TO GET FULL VALUE FROM THE PRACTICE. IF NOT...

    C++ Program classes READ THE FOLLOWING CAREFULLY TO GET FULL VALUE FROM THE PRACTICE. IF NOT COMFORTABLE WITH CLASSES, I WOULD START WITH DEFINING THE CLASS WITH ONE constructor AND GO FROM THERE Use the following to calculate a GPA (the following is for calculation information only): A = 4.00 grade points per credit hour A- = 3.70 grade points per credit hour B+ = 3.33 grade points per credit hour B = 3.00 grade points per credit hour B-...

  • Problem Specification: Write a C++ program to calculate student’s GPA for the semester in your class. For each student, the program should accept a student’s name, ID number and the number of courses...

    Problem Specification:Write a C++ program to calculate student’s GPA for the semester in your class. For each student,the program should accept a student’s name, ID number and the number of courses he/she istaking, then for each course the following data is needed the course number a string e.g. BU 101 course credits “an integer” grade received for the course “a character”.The program should display each student’s information and their courses information. It shouldalso display the GPA for the semester. The...

  • use c++ Weighted GPA Calculator2 Many schools factor in the number of credits each course is...

    use c++ Weighted GPA Calculator2 Many schools factor in the number of credits each course is worth, meaning a 4-credit class has more value than a 2-credit class when calculating students GPA Suppose the following were the grades for a student CreditsGrade lass Pre-Calculus History Chemistry Physical Education 1 Letter grades are assigned as follows Letter grades are worth these points 0-60 F 61 -70 D 71 80 C 81 -90 B 91 -100 A Class Pre-Calculus History Chemistr)y Physical...

  • Create a program in Python to change Grades in number and find the GPA of the...

    Create a program in Python to change Grades in number and find the GPA of the user Problem: The user wants an easy calculator to calculate their GPA. They want to enter the letter grade (A, B, C, D, F) for 5 classes, the credit hours (1, 2, 3,4, 5) and then run the program to calculate the GPA (3.50- 4.00 A, 3.49 – 2.50 B, 2.49 -1.60 C, 1.59 – .50 D, .49 -0 F) for the semester. Task...

  • (7) Student grade point statistics [Problem description] There is a need to make statistics of the grade points o...

    (7) Student grade point statistics [Problem description] There is a need to make statistics of the grade points of the students in the first semester of 2018. It is assumed that there are n (can be set as 6) classes in this grade, and there are 20 students in each class, the total number of courses with exam is m (can be set as 10), and the percentage system is adopted for each course. The gpa is 4, 3, 2,1,...

  • 2. The data file studentData.txt contains a list of student's name, major, grade points, and cred...

    please solve this Java program. I need some explain. 2. The data file studentData.txt contains a list of student's name, major, grade points, and credit hours. The number of students is unknown. The data file is on D2L. studentData.txt Major Grade Points Credit Hours Name Jacob Michael Joshua Matthew Samantha CS Math CS Art Business 42 80 48 39 100 12 25 12 10 34 UK Write a program that reads the data from the data file, calculates the GPA...

  • Help me write the program in C++ Thanks Program #1: Calculate a student's grade for a...

    Help me write the program in C++ Thanks Program #1: Calculate a student's grade for a class. The class has 4 categories of grades. Each category has different weights. The student's report should include the student's first and last name; course; semester, category listing with weight for each category, grades for each category and the student's final average with a letter grade. Categories with weights: 1. Exams: 30%(3 @ 10% each) 2. Labs: 30% (3 labs @ 10% cach) 3....

  • Program 5 Due 10/25 C-String and Two-dimensional Array Use An input data file starts with a...

    Program 5 Due 10/25 C-String and Two-dimensional Array Use An input data file starts with a student's name (on one line). Then, for each course the student took last semester, the file has 2 data lines. The course name is on the first line. The second line has the student's grade average (0 to 100) and the number of credits for the course Sample data: Jon P. Washington, Jr. Computer Science I 81 4 PreCalculus 75 3 Biology I 88...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT