Question

In: Computer Science

C# CODE C# 1) Write a program that calculates a student's GPA. Remember, an A is...

C# CODE C#

1) Write a program that calculates a student's GPA. Remember, an A is worth 4 points, a B is worth 3 points, a C is worth 2 points, a D is worth 1 point, and an F is worth 0 points. For the purposes of this assignment, assume that all classes carry the same number of credit hours.

2) Use a sentinel-controlled loop to gather a variable number of letter grades. This should terminate the loop if the user enters an "X." This means that users should input as many grades as they like. When they are finished, they need to input an X, and at that point, the program will return the results.

C# CODE C# THANK YOU!

Solutions

Expert Solution

Assumption, here is the same number of credit hours here is 2.

The formula of GPA is as below

The C# code with sample output is as below.

using System;

class GPACalculator
{
static void Main()
{
char input;
int sum= 0,points=0;
int credit = 2,sumCredit=0;
//sentinel controlled loop
while (true)
{
Console.Write("Enter a grade- A,B,C,D or F (X to quit) : ");
//character input
input = Console.ReadLine()[0];
//break the loop only when input is X///
if (input == 'X')
{
break;
}
//assign points depending on grades using switch statement
switch(input){
case 'A':
points = 4;
break;
case 'B':
points = 3;
break;
case 'C':
points = 2;
break;
case 'D':
points = 1;
break;
case 'F':
points = 0;
break;
}
//find total credits in sumCredit and total points earned in points*credit
sum += (points*credit);
sumCredit +=credit;
}
//find the gpa and display
Console.WriteLine($"GPA of the student is = {sum / (double)sumCredit}");
}
}

sample output


Related Solutions

Question: How do I write a program in C# that calculates a student's final grade for...
Question: How do I write a program in C# that calculates a student's final grade for a test with 20 multiple questions using arrays and helper methods? Instructions: (0-incorrect answer, 1-correct answer) If the student answered the question right, add .5 points to the running total. If the student didn’t answer correctly subtract .5 points from the running total. The running total is initialized with 5 points (so the student receives 5 points extra credit). To define the final grade...
1. Write the C++ code for a program that calculates how many days are left until...
1. Write the C++ code for a program that calculates how many days are left until Halloween, when given as an input how many weeks are left until Halloween. Use variables named weeks and days. ------------ 2. What header file must be included - To perform mathematical functions like sqrt? - To use cin and cout? - To use stream manipulators like setprecision? -------------------- 3. What value will be stored in the variable t after each of the following statements...
Write a program that calculates the student's final grade for a test with 20 multiple questions...
Write a program that calculates the student's final grade for a test with 20 multiple questions using C# .net Framework. se an array of integers to store the test scores (0-incorrect answer, 1-correct answer). Initialize it as follows: int [] scores = {1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1}; 3. If the student answered the question right, add 5 points to the running total. If the student...
Programming Assignment 1 Performance Assessment Objective: To write a C program (not C++) that calculates the...
Programming Assignment 1 Performance Assessment Objective: To write a C program (not C++) that calculates the average CPI, total processing time (T), and MIPS of a sequence of instructions, given the number of instruction classes, the CPI and total count of each instruction type, and the clock rate (frequency) of the machine. The following is what the program would look like if it were run interactively. Your program will read values without using prompts. Inputs: • Clock rate of machine...
Programming Assignment 1 Performance Assessment Objective: To write a C program (not C++) that calculates the...
Programming Assignment 1 Performance Assessment Objective: To write a C program (not C++) that calculates the average CPI, total processing time (T), and MIPS of a sequence of instructions, given the number of instruction classes, the CPI and total count of each instruction type, and the clock rate (frequency) of the machine. The following is what the program would look like if it were run interactively. Your program will read values without using prompts. Inputs: • Clock rate of machine...
1. To compute a student's Grade Point Average (GPA) for a term, the student's grades for...
1. To compute a student's Grade Point Average (GPA) for a term, the student's grades for each course are weighted by the number of credits for the course. Suppose a student had these grades: 4.0 in a 5 credit Math course 2.1 in a 2 credit Music course 2.8 in a 5 credit Chemistry course 3.0 in a 4 credit Journalism course What is the student's GPA for that term? Round to two decimal places. Student's GPA = 2.A set...
Your task is to write a program in C or C++ that calculates the total amount...
Your task is to write a program in C or C++ that calculates the total amount of money a person has made over the last year. Your program will prompt the user for dollar amounts showing how much the user has made per job. Some users will have had more than one job, make sure your program allows for this. The program will print out the total made (all jobs) and will print out the federal and state taxes based...
Write a C++ program that calculates mileage reimbursement for a salesperson at a rate of $...
Write a C++ program that calculates mileage reimbursement for a salesperson at a rate of $ 0.35 per mile. Your program should interact with the user in this manner: MILEAGE REIMBURSEMENT CALCULATOR Enter beginning odometer reading: 13505.2 Enter ending odometer reading     : 13810.6 You traveled 305.40 miles. At $ 0.35 per mile, your reimbursement is $ 106.89. The values in red color are inputs for the program. The values in blue color are results of expressions.
Write a program in C++ that calculates the sum of two fractions. The program should ask...
Write a program in C++ that calculates the sum of two fractions. The program should ask for the numerators and denominators of two fractions and then output the sum of the two fractions. You will need to write four functions for this program, one to read the inputted data, one to calculate the sum of the two fractions, one to find the Greatest Common Divider (GCD) between the numerator and denominator and a function that will display the end result....
Write a C program that calculates a student grade in the C Programming Class. Ask the...
Write a C program that calculates a student grade in the C Programming Class. Ask the user to enter the grades for each one of the assignments completed in class: Quiz #1 - 25 points Quiz #2 - 50 points Quiz #3 - 30 points Project #1 - 100 points Project #2 - 100 points Final Test - 100 points The total of the quizzes count for a 30% of the total grade, the total of the projects counts for...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT