Question

In: Computer Science

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, 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. Must be in C#.

Solutions

Expert Solution

In C sharp

using System;

namespace BoxApplication

{

    class GPA

    {

        static void Main(string[] args)

        {

            double CH, num, c1 = 0.0, c2 = 0.0;

            char grade;

            // ask the user for the number of subjects

            Console.WriteLine("\nEnter the number of subjects: ");

            num = Convert.ToInt32(Console.ReadLine());

/* ask quality points and credit hours for each of the

subjects and calculate the total quality points and

the total credit hours */

            for (int i = 0; i < num; i++)

            {

                Console.WriteLine("\nEnter the grade (A / B / C / D): ");

                grade = Console.ReadKey().KeyChar;

                Console.WriteLine("\nEnter the credit hours:");

                CH = Convert.ToInt32(Console.ReadLine());

                c1 = c1 + CH;

                if (grade == 'A')

                { c2 = c2 + 4 * CH; }

                if (grade == 'B')

                { c2 = c2 + 3 * CH; }

                if (grade == 'C')

                { c2 = c2 + 2 * CH; }

                if (grade == 'D')

                { c2 = c2 + 1 * CH; }

            }

            /*calculate GPA by dividing the total quality

             * points by total credit hours and print the result

             */

            Console.WriteLine("\n\n-------------------------------------------------\n");

            Console.WriteLine("-------------------------------------------------\n");

            Console.WriteLine("Total grades earned by the student is :");

            Console.WriteLine(c2);

            Console.WriteLine("\nTotal credit hours earned by the student is :");

            Console.WriteLine(c1);

            Console.WriteLine("\nGPA of the student is :");

            Console.WriteLine(c2 / c1);

            Console.ReadKey();

            Console.ReadKey();

        }

    }

}

Code screenshot:

Output:


Related Solutions

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...
Write an application that allows a user to enter any number of student quiz scores, as...
Write an application that allows a user to enter any number of student quiz scores, as integers, until the user enters 99. If the score entered is less than 0 or more than 10, display Score must be between 10 and 0 and do not use the score. After all the scores have been entered, display the number of valid scores entered, the highest score, the lowest score, and the arithmetic average.
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 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...
2. Write a c++ program that takes from the user the ​number of courses​ and constructs...
2. Write a c++ program that takes from the user the ​number of courses​ and constructs 3 ​dynamic 1D arrays​ with size courses+1. Each array represents a student. Each cell in the array represents a student’s mark in a course. In the last cell of each 1D array you should calculate the average mark of that student. Then output the average mark of all students in each course. Delete any allocated memory. Example Number of courses : 4 50 60...
Create a simple shopping cart application. Ask the user to input an item number and quantity....
Create a simple shopping cart application. Ask the user to input an item number and quantity. Update the shopping cart. Display the updated cart. Include the following when displaying cart: item number, name, quantity and total price. Ask for another update or end the program. Design Requires 2 classes: the main class and the cartItem class In the main class: Need one array named cartArray of type cartItem. Size = ? Need a loop that asks the user for input....
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 an application that asks a user to type an even number or the sentinel value...
Write an application that asks a user to type an even number or the sentinel value 999 to stop. When the user types an even number, display the message “Good job!” and then ask for another input. When the user types an odd number, display an error message, "x is not an even number", and then ask for another input. When the user types the sentinel value 999, end the program.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT