Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please help in C + + Your job is to design and create a program to calculate the letter grade based on a numerical score.

Please help in C++
Your job is to design and create a program to calculate the letter grade based on a numerical score. You will first read the numerical scores from the user as input into a double array, and then calculate the letter grade and fill another parallel array and print the two arrays as output.
The numerical score must be between 0 and 4 inclusive. The user should not be allowed to enter a score less than 0 or greater than 4.
Write the following functions and call them in the same order as instructed in the main() function to accomplish this Task.
void welcome()- This function prints a welcome message to the user.
void readScores(double scores[], int &count)
Reads a list of scores from the user. A -1 indicates the end of the input and is not stored in the array. (Use an appropriate loop!! Check out this example code - a for loop is count controlled, and a while loop is condition based.)
Call the readDouble function to do this. You must catch all invalid data such as characters, negative numbers other than -1 etc.
The variable count keeps track of the number of scores entered.
You must also do validation to make sure that the number is between 0 and 4 inclusive and nothing other than that. Use a while loop to do this.
void readDouble(string prompt, double &num)
This function should be used any time you read any floats or doubles from the user. Use this function to read the numerical scores from the user.
It takes a string prompt, outputs it, reads a number from the user, validates and returns the num by reference.
Write it exactly like the readInt from assignment 1 but declare a double or float instead of an int. See Samplea01.cpp for the readInt function.
You must catch all invalid data such as characters, negative numbers etc.
void calcGrade(double scores[], char grade[], int count)
Use a loop to process each array element and calculate the letter grade for each score.
Use the table below to assign grades A to F to the corresponding numerical score.
Letter Grade
4.0 Score
Level
A
>3.3<=4.0
Exceeds
B
>2.7<=3.3
Meets
C
>1.9<=2.7
Approaching
D
>1.2<=1.9
Not Yet
F
>0.0<=1.1
No Evidence
void printList(double scores[], char grades[], int count)
Go through a for loop and print the scores and the corresponding grades for each item.
void sort(double scores[], char grade[], int count)
Sort the arrays using the given sorting algorithm. This is called Selection Sort. Use only this algorithm to sort your list. To see how the Selection Card Sort Algorithm works, watch this video from Virginia Tech.
Be careful and make sure you sort based on the scores array and swap the corresponding element in the grade array to maintain the correspondence between the two arrays. Meaning if you swap the scores in index 0 and 5, you must also swap the corresponding grades in index 0 and 5.
Watch this Python Video to help you with the sorting algorithm. Try this Selection Sort Animation by Y. Daniel Liang.
procedure selection sort
list : array of items
count : size of list
for i =0 to count -1
/* set current element as minimum*/
min = i
/*go through the list and find the smallest element*/
for j = i+1 to count
if list[j]< list[min] then
min = j;
end if
end for
/* swap the minimum element with the current element
If they are not the same element*/
if min != i then
swap list[min] and list[i]
end if
end for
end procedure
int main()
Declare all variables needed. The 2 arrays (double scores[], and char grades[]) must be declared in main().
Call readScores() and send scores and count to it. This will fill the scores array from the user. You should call the readDouble() function to read and validate the scores before adding them to the scores array.
count will have the number of values read.
Call calcGrade()function that takes the scores array and an empty grades array and fills the grades array with letter grades.
Call the printList function to print the lists.
Call the sort function to sort the list based on scores.
Call the printList function to print the lists.
Assume the arrays will always contain fewer than 20 scores. You must not let the user enter more than 20 scores.
Open the Algorithmic Design Document, make a copy, and follow the steps to create your algorithm.
You must express your algorithm as pseudocode.
Here is the expected output.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Sql All In One For Dummies 7 Books In One

Authors: Allen G Taylor ,Richard Blum

4th Edition

1394242298, 978-1394242290

More Books

Students also viewed these Databases questions

Question

Organizing Your Speech Points

Answered: 1 week ago