Question

In: Computer Science

Problem: Grading Function #Write a function called getScore() that does not take any parameter. Inside the...

Problem: Grading Function

#Write a function called getScore() that does not take any parameter. Inside the function, it asks the user to input scores for 3 items (Each of the items is out of 100). The final score is calculated by 20% of item1 + 30% of item2 + 50% of item3. After calculating the final score, the function returns it to the caller. The scores are floating-point numbers.

#Write another function called getLetterGrade() that takes a float parameter and returns the letter grade based on the number passed to it as an actual parameter.

#Write the main function to test your program.

Call the getScore() function from the main function and after getting the final score from the getScore function, you should call the getLetterGrade() function to get the Grade for that score. Then print the letter grade returned by the getLetterGrade() function.

Here is the scale of the letter grade:

  • A [>=90]

  • B [80 – 90)

  • C [70 – 80)

  • D[ 60 – 70)

  • F [<60]

Solutions

Expert Solution

#include<iostream>
using namespace std;
float getScore(){
   float i1,i2,i3;
   cout<<"Enter 3 scores: ";
   cin>>i1>>i2>>i3;
   float total = i1 * 0.2 + i2 * 0.3 + i3 * 0.5;
   return total;
}
char getLetterGrade(float f){
   if(f>=90)
       return 'A';
   if(f>=80)
       return 'B';
   if(f>=70)
       return 'C';
   if(f>=60)
       return 'D';
   return 'F';
}
int main(){
   float total=getScore();
   cout<<"Grade: "<<getLetterGrade(total);
}

Note : Please comment below if you have concerns. I am here to help you

If you like my answer please rate and help me it is very Imp for me


Related Solutions

Task 04: Running Average Write a function average that does not take any parameter and asks...
Task 04: Running Average Write a function average that does not take any parameter and asks the user to enter a positive number in a loop. The loop terminates when the user enters a negative number and the average is printed on the console. The function does not return any value. Save the function in a PyDev library module named functions.py Write a main program named t04.py that tests the function. Sample run: Enter a positive number: 2 Enter a...
Write a Racket function that will take a list of numbers as a parameter and return...
Write a Racket function that will take a list of numbers as a parameter and return true if they all are positive, and false otherwise. You are NOT required to check the type of elements in the list. (please do on racket language)
Write a Racket function that will take a list of numbers as a parameter and return...
Write a Racket function that will take a list of numbers as a parameter and return true if they all are positive, and false otherwise. You are NOT required to check the type of elements in the list.
- Write a function with a parameter called A (which is between 1 and 10) and...
- Write a function with a parameter called A (which is between 1 and 10) and prints the multiplication table for 1 to A. • Note: Do not need to draw the horizontal and vertical lines. • Example for A = 10.
(C++) In a file called pp7c.cpp, write a function called printMoney that has one parameter, a...
(C++) In a file called pp7c.cpp, write a function called printMoney that has one parameter, a double, and it prints this parameter out formatted like a dollar amount with $ and exactly 2 digits to the right of the decimal. Write a driver that declares an array of monetary amounts like this: double amounts[MAX_AMOUNTS]; and uses a while or do while loop to ask the user for monetary amounts with -1 for the amount as a sentinel value to put...
create overloaded functions called lastValue. The first function should take as a parameter a string and...
create overloaded functions called lastValue. The first function should take as a parameter a string and the second function should take as a parameter an int. each of you functions should return an int value. in the case of the function that takes the string as an argument you will return the ascii value of the last character in the string. in the case of the function that takes an int parameter your function will return the last digit in...
#Write a function called "load_file" that accepts one #parameter: a filename. The function should open the...
#Write a function called "load_file" that accepts one #parameter: a filename. The function should open the #file and return the contents.# # # - If the contents of the file can be interpreted as # an integer, return the contents as an integer. # - Otherwise, if the contents of the file can be # interpreted as a float, return the contents as a # float. # - Otherwise, return the contents of the file as a # string. #...
C++ Write a function called linearSearch that takes an array as a parameter and search for...
C++ Write a function called linearSearch that takes an array as a parameter and search for a specific value inside this parameter. The function returns the frequency of a specific value in the array. In the main function: 1. Define an array called salaries of length 5. 2. Initialize the array by asking the user to input the values of its elements. 3. Define a variable called key and ask the user to enter a value for this variable. 4....
Write a recursive function in python called make_palindrome that takes a sequence as a parameter and...
Write a recursive function in python called make_palindrome that takes a sequence as a parameter and returns a new sequence that is twice the length of the parameter sequence but that contains the contents of the original in palindrome form. For example, if the sequence "super" is passed into the function, the function will return "superrepus".
Write a function called remove_punct() that accepts a string as a parameter, removes the punctuation (',',...
Write a function called remove_punct() that accepts a string as a parameter, removes the punctuation (',', '!', '.') characters from the string, and returns the number of punctuation characters removed. For example, if the string contains ['C', 'p', 't', 'S', ',', '1', '2', '1', '.', 'i', 's', 'f', 'u', 'n', '!', '\0'], then the function should remove the punctuation characters. The function must remove the characters by shifting all characters to the right of each punctuation character, left by one...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT