Question

In: Computer Science

Write application in C# that enables a user to: Use Methods for user input and calculations...

Write application in C# that enables a user to:

Use Methods for user input and calculations

input the grade and number of credit hours for any number of courses.

Calculate the GPA on a 4.0 scale using those values. Grade point average (GPA) is calculated by dividing the total amount of grade points earned, sometimes referred to as quality points, by the total number of credit hours attempted. For each hour, an A receives 4 grade or quality points, a B receives 3 points, a C receives 2 points, and a D receives 1 point. Thus, a three-credit hour course receiving an A would have 12 quality points associated with the course.

Allow the user to input any number of courses and associated grades.

Display the number of hours earned and the calculated GPA.

Solutions

Expert Solution

Code for the given problem:

For each course,

  • Add all grade points earned.
  • Find maximum grade points that can be earned.
  • Compute total hours earned.
using System;

public class Test
{
        public static void Main()
        {
            int n;
            int total_grades = 0;
            int max_grades = 0;
            int total_hours = 0;
            
            n = int.Parse(Console.ReadLine());
            
            for (int i=0; i<n; i++) {
                string[] tokens = Console.ReadLine().Split();
    
            string grade = tokens[0];
            int g;
            if(grade=="A")
                g=4;
            else if(grade=="B")
                g=3;
            else if(grade=="C")
                g=2;
            else
                g=1;
            
            int h = int.Parse(tokens[1]); 
            
            total_grades += g*h;
            total_hours += h;
            max_grades += 4*h;
            }
            
            float gpa = 0.0f;
            gpa = ((float)total_grades / max_grades)*4;
            
            Console.WriteLine("Number of hours earned = {0}, GPA = {1}", total_hours, gpa);
        }
}

Input format:

  • Enter number of courses
  • For each course, in a separate line, enter grade and number of credit hours

  

Output format:

  • After computing GPA, display the number of hours earned and the calculated GPA.


Related Solutions

Write application that enables a user to input the grade and number of credit hours for any number of courses.
Write application that enables a user to input the grade and number of credit hours for any number of courses. Calculate the GPA on a 4.0 scale using those values. Grade point average (GPA) is calculated by dividing the total amount of grade points earned, sometimes referred to as quality points, by the total number of credit hours attempted. For each hour, an A receives 4 grade or quality points, a B receives 3 points, a C receives 2 points,...
CODE IN C PLEASE Ask for user to input 4 different numbers Use pointers in calculations...
CODE IN C PLEASE Ask for user to input 4 different numbers Use pointers in calculations instead of variables to calculate the sum of those 4 numbers Print the sum Use a pointer to a pointer for print operation
Write a Java application with a JavaFXGUI that takes a String input by the user and...
Write a Java application with a JavaFXGUI that takes a String input by the user and shows whether the string contains all 26 letters of the (English version of the Latin) alphabet. For example, "Pack my box with five dozen liquor jugs" contains all 26 letters, but "The quick frown box jumps over the hazy log" does not contain a d. It does not matter whether one or more letters appear more than once. The GUI needs, at minimum, a...
Write a Java application with a JavaFXGUI that takes a String input by the user and...
Write a Java application with a JavaFXGUI that takes a String input by the user and shows whether the string contains all 26 letters of the (English version of the Latin) alphabet. For example, "Pack my box with five dozen liquor jugs" contains all 26 letters, but "The quick frown box jumps over the hazy log" does not contain a d. It does not matter whether one or more letters appear more than once. The GUI needs, at minimum, a...
Java Code: Write an application that takes in user input. (Name, Age, and Salary) ------ Write...
Java Code: Write an application that takes in user input. (Name, Age, and Salary) ------ Write an application that includes a constructor, user input, and operators.
Write a C++ Program Write a program that prompts the user to input a string. The...
Write a C++ Program Write a program that prompts the user to input a string. The program then uses the function substr to remove all the vowels from the string. For example, if str=”There”, then after removing all the vowels, str=”Thr”. After removing all the vowels, output the string. Your program must contain a function to remove all the vowels and a function to determine whether a character is a vowel. You must insert the following comments at the beginning...
Write an application and perform the following:(NO USER INPUT) -Create at least three classes such as:...
Write an application and perform the following:(NO USER INPUT) -Create at least three classes such as: 1. listnode- for data and link, constructors 2. Singlelinkedlist-for method definition 3. linkedlist-for objects -Insert a node at tail/end in a linked list. -and display all the nodes in the list. -Delete a node at a position in the list Note: Add these methods in the same application which we have done in the class. this is what we've done in the class: class...
Write a program in c++ that prompts the user to input a coin collection of number...
Write a program in c++ that prompts the user to input a coin collection of number of quarters, dimes, nickels and pennies. The program should then convert the coin collection into currency value as dollars. The coin values should all be whole numbers and the resulting currency value should be displayed with two decimals. An example of user interaction is as follows: Coin Convertor Enter number of quarters: 3 Enter number of dimes: 1 Enter number of nickels: 4 Enter...
Write a program in C, that uses standard input and output to ask the user to...
Write a program in C, that uses standard input and output to ask the user to enter a sentence of up to 50 characters, the ask the user for a number between 1 & 10. Count the number of characters in the sentence and multiple the number of characters by the input number and print out the answer. Code so far: char sentence[50]; int count = 0; int c; printf("\nEnter a sentence: "); fgets(sentence, 50, stdin); sscanf(sentence, %s;    for(c=0;...
Ask the user to input a series of numbers, write a C# program to output the...
Ask the user to input a series of numbers, write a C# program to output the sum, max, and min. Be sure to do error checking if the user input is not a number.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT