Write a program that asks the user to enter five test scores. The program should display a letter grade for each score and the average test score. Design the following functions in the program: calcAverage—This function should accept five test scores as arguments and return the average of the scores. determineGrade—This function should accept a test score as an argument and return a letter grade for the score (as a String), based on the following grading scale:
Score Letter Grade 90–100 A 80–89 B 70–79 C 60–69 D Below 60 F
1- Complete the following function IPO Charts for calcAverage function, determineGrade function, getValidScore function, isValidScore function.
2- write pseudocode for calcAverage function, determineGrade function, getValidScore function, isValidScore function.
Program:
#include <stdio.h>
int calcAverage(int a[]);
void determineGrade(int a);
int main()
{
int a[5],average;
printf("Enter 5 Test Scores:");
for(int i = 0; i<5;i++)
{
scanf("%d",&a[i]);
}
printf("\nGrades:\n");
for(int i = 0; i<5;i++)
{
determineGrade(a[i]);
}
average = calcAverage(a);
printf("\n\nAverage: %d",average);
return 0;
}
//Function to calculate Average
int calcAverage(int a[])
{
int avg,sum=0;
for(int i=0;i<5;i++)
{
sum = sum+a[i];
}
avg = sum / 5;
return avg;
}
//Function to determine Grade
void determineGrade(int a)
{
if(a>=90 && a<=100)
{
printf("%d - A\n",a);
}
if(a<=89 && a>=80)
{
printf("%d - B\n",a);
}
if(a<=79 && a>=70)
{
printf("%d - C\n",a);
}
if(a<=69 && a>=60)
{
printf("%d - D\n",a);
}
if(a<60)
{
printf("%d - FAIL\n",a);
}
}
1. IPO CHARTS:
a> CalcAverage Function
INPUT |
PROCESS |
OUTPUT |
Test Scores |
Ø Sum the test scores Ø Divide Sum of test scores with 5 Ø Output Average |
Average |
b> determineGrade Function:
INPUT |
PROCESS |
OUTPUT |
Test Scores |
Ø Score >= 90 AND score <= 100 Display "A" Ø score <= 89 AND score >= 80 Display "B" Ø score<=79 AND score >= 70 Display "C" Ø score <= 69 AND score >= 60 Display "D" Ø score < 60 Display "FAIL" |
Grades |
c> getValidScore Function
INPUT |
PROCESS |
OUTPUT |
Test Scores |
Ø Score >= 0 AND score <= 100 Return Score |
Score |
d> isValidScore Function
INPUT |
PROCESS |
OUTPUT |
Test Scores |
Ø Score >= 0 AND score <= 100 Display "ValidScore" Ø Score < 0 OR score > 100 Display "IN ValidScore" |
Valid/Invalid Score |
2)
Pseudocodes:
a> CalcAverage Function
Initialize sum to 0 // Initialising a variable to calculate sum
of numbers
FOR i IN 1 TO 5
DO sum = sum+a[i] // Calculating sum of all numbers in
the array
ENDFOR;
avg = sum / 5 // Calculating Average of all the numbers i.e; Avg =
(Sum Of Num)/Total num
Print avg // Prints The Average
b> determineGrade Function:
IF marks>=90 AND marks<=100 // Conditonal Statement to
check whether the marks >=90 & mark<=100
Print "A" //then it prints Grade 'A'
ENDIF
IF marks<=89 AND marks>=80 //Conditonal Statement to check
whether the marks <=89 & mark>=80
Print "B" //then it prints Grade 'B'
ENDIF
IF marks<=79 AND marks>=70 //Conditonal Statement
to check whether the marks <=79 & mark>=70
Print "C" //then it prints Grade 'C'
ENDIF
IF marks<=69 AND marks>=60 //Conditonal Statement to check
whether the marks <=69 & mark>=60
Print "D" //then it prints Grade 'D'
ENDIF
IF marks<60 //Conditonal Statement to check whether the marks
< 60
Print "Fail" //then it prints 'FAIL'
ENDIF
c> isValidScore Function
IF marks>=0 AND marks<=100 // Valid score is between marks 0
and 100
RETURN True // If user enters the score between the range 0 and 100
then it returns TRUE
ELSE
RETURN False // If user doesn't enters the score between the range
0 and 100 then it returns FALSE
ENDIF
c> getValidScore Function
IF marks>=0 AND marks<=100 // Valid score is between marks
0 and 100
return marks // If user enters the score between the
range 0 and 100 then it returns marks
ELSE
return -1 // If user doesn't enters the score between the range 0
and 100 then it returns -1
ENDIF
Write a program that asks the user to enter five test scores. The program should display...
Design a function named max that accepts two integer values as arguments and returns the value that is the greater of the two. For example, if 7 and 12 are passed as arguments to the function, the function should return 12. Use the function in a program that prompts the user to enter two integer values. The program should display the value that is the greater of the two. Need Variable lists, Psuedocode, ipo chart, Flow Chart, and a python...
Solve This Problem using python and please comment on every
line. also, use function to solve this.
thanks
The result will be like as below:
Write a program that asks the user to enter five test scores. The program should display a letter grade for each score and the average test score. Write the following functions in the program: This function should accept five test scores as arguments and return the average of the scores. This function should accept a...
Test Scores and Grade
Write a program that has variables to hold three test scores.
The program should ask the user to enter three test scores and then
assign the values entered to the variables. The program should
display the average of the test scores and the letter grade that is
assigned for the test score average. Use the grading scheme in the
following table:
Test Score Average
Letter Grade
90–100
A
80–89
B
70–79
C
60–69
D
Below 60...
This question was answered by someone else but their code
doesn't work when I try to run it.
Q1. Currently, you are enrolled in the Spring semester and taking five courses. Write a program that asks the user to enter the final score of each course. The program should display a letter grade for each class, a statement based on a letter grade, and a spring semester GPA. Each course has 3 credit hours. Write the following functions in the...
Write a C++ program that will provide a user with a grade range if they enter a letter grade. Your program should contain one function. Your function will accept one argument of type char and will not return anything (the return type will be void), but rather print statements to the console. Your main function will contain code to prompt the user to enter a letter grade. It will pass the letter grade entered by the user to your function....
in
java plz
amaining Time: 1 hour, 49 minutes, 15 seconds. Jestion Completion Status: Write a program that asks the user for an input file name, open, read ar number of students is not known. For each student there is a name and and display a letter grade for each student and the average test score fc • openFile: This method open and test the file, if file is not found and exit. Otherwise, return the opened file to the...
I need help with this c++ question please
thank you
ltls. The program should urt valte. 11. Lowest Score Drop Write a program that calculates the average of a group of test scores, where the lowest score in the group is dropped. It should use the following functions: void getscore() should ask the user for a test score, store it in a reference param- eter variable, and validate it. This function should be called by main once for each of...
Using basic c++ write 2 separate codes for this assignment. Program #1 Write a program that calculates the average of a group of test scores, where the lowest score in the group is dropped. It should use the following functions. • void getScore() should ask the user for a test score, store it in the reference parameter variable, and validate it. This function should be called by the main once for each of the five scores to be entered. •...
Write a program that will ask the user to enter 4 quiz scores. These scores should be from 0 to 100. Use a procedure and pass by reference to get these scores. Write a function that will find the lowest score. This score will be sent back through the function call. You still need to pass the scores by value to this function. Write a function that will calculate the average score. This value will be sent back to main...
Write a Python program that asks the user to type in their three quiz scores (scores between 0 and 100) and displays two averages. The program should be written so one function gets the user to input a score, another function takes the three scores and returns the average of them. And another function takes the three scores and averages the two highest scores (in other words, drops the lowest). Each of these functions should do the computation and return...