Question

In: Computer Science

ASSIGNMENT: Write a program to ask for the name and test score for 8 students, validate...

ASSIGNMENT:

Write a program to ask for the name and test score for 8 students, validate that the test score is between 0.0 and 100.0 inclusive, and store the names and test scores in 2 parallel arrays. Then, calculate and display the average of the test scores. Finally, display all the students who have test scores above the average.

Example Run #1:

(bold type is what is entered by the user)

Enter student name #1: George
Enter the score for George: 90

Enter student name #2: Sam
Enter the score for Sam: 65

Enter student name #3: Billy
Enter the score for Billy: 123
The score entered for Billy was not in the range of 0.0 to 100.0.
Please re-enter the score for Billy: 83.5

Enter student name #4: Bob
Enter the score for Bob: -5
The score entered for Bob was not in the range of 0.0 to 100.0.
Please re-enter the score for Bob:
56.7

Enter student name #5: Phil
Enter the score for Phil: 83

Enter student name #6: Scott
Enter the score for Scott: 0

Enter student name #7: Suzanne
Enter the score for Suzanne: 73.4

Enter student name #8: Joe
Enter the score for Joe: 69


The average of the scores is xx.x%.

George has a score of 90.0, which is above average.
Billy has a score of 83.5, which is above average.
Phil has a score of 83.0, which is above average.
Suzanne has a score of 73.4, which is above average.
Joe has a score of 69.0, which is above average.

The example run shows EXACTLY how your program input and output will look.

C programming NO FLOATS

Solutions

Expert Solution

** I request you to Please Provide the positive Rating**

SOURCE CODE:
#include <stdio.h>

int main()
{
int n=8,i,sum=0;
char names[10][8];
int scores[10];
float avgscore;
for (int i=0; i<n;i++)
{
printf("\n enter the student name:\n ");
scanf(" %s",names+i);
printf("\n enter the score:");
scanf("%d",&scores[i]);
sum=sum+scores[i];
}
avgscore=sum/n;
printf("\n The average of the scores is %f \n",avgscore);
for(i=0;i<n;i++)
{
if(scores[i]>avgscore)
{
printf("\n%s has a score %d which is above average\n ", names+i, scores[i]);
}
}
return 0;
}
OUTPUT:

enter the student name:
george

enter the score:56

enter the student name:
joe

enter the score:47

enter the student name:
pinky

enter the score:98

enter the student name:
sanju

enter the score:23

enter the student name:
sushu

enter the score:75

enter the student name:
wicky

enter the score:46

enter the student name:
shriya

enter the score:65

enter the student name:
shannu

enter the score:12

The average of the scores is 52.000000

george has a score 56 which is above average

pinky has a score 98 which is above average

sushu has a score 75 which is above average

shriya has a score 65 which is above average


Related Solutions

Ice Cream Program Assignment Write a program that uses a function to ask the user to...
Ice Cream Program Assignment Write a program that uses a function to ask the user to choose an ice cream flavor from a menu (see output below.) You must validate the users input for the flavor of ice cream accounting for both upper and lower-case letters. You must give them an appropriate error message and allow them to try again.   Once you have a valid flavor, your function will return the flavor back to the main() function.    Your main()...
java programming write a program with arrays to ask the first name, last name, middle initial,...
java programming write a program with arrays to ask the first name, last name, middle initial, IDnumber and 3 test scores of 10 students. calculate the average of the 3 test scores. show the highest class average and the lowest class average. also show the average of the whole class. please use basic codes and arrays with loops the out put should look like this: sample output first name middle initial last name    ID    test score1 test score2...
Write a program using C language that -ask the user to enter their name or any...
Write a program using C language that -ask the user to enter their name or any other string (must be able to handle multiple word strings) - capture the epoch time in seconds and the corresponding nanoseconds - ask the user to type in again what they entered previously - capture the epoch time in seconds and the corresponding nanoseconds -perform the appropriate mathematical calculations to see how long it took in seconds and nanoseconds (should show to 9 decimal...
8. An SAT prep course claims to improve the test score of students. The table below...
8. An SAT prep course claims to improve the test score of students. The table below shows the scores for seven students the first two times they took the verbal SAT. Before taking the SAT for the second time, each student took a course to try to improve his or her verbal SAT scores. Do these results support the claim that the SAT prep course improves the students' verbal SAT scores? Let d=(verbal SAT scores prior to taking the prep...
(8 marks) Write a program to ask user to enter an integer that represents the number...
Write a program to ask user to enter an integer that represents the number of elements, then generate an ArrayList containing elements which are all random integers in range [75, 144] , and finally display index and value of each element. REQUIREMENTS The user input is always correct (input verification is not required). Your code must use ArrayList. Your program must use only printf(…) statements to adjust the alignment of your output. Your code must display the index in descending...
Write a Java program thatdoes the following jobs.Step1. Creates a Schooltable with name, score, rating, and...
Write a Java program thatdoes the following jobs.Step1. Creates a Schooltable with name, score, rating, and district.Step2. Reads data from theCSVfile(elementrayschool.csv)and insert the schoolsinto the table created in Step 1.Step3. Interact with the user, wheretheusercan select one of the following actions.-(Q) Quit: quit the program-(A) Add a school-(C) Calculate average rating-(S) Print a subset of the schools based on score-(D) Print a subset of the schools based on districtThe user can choose one of these actions bytyping Q,A,C, S, or...
1. INTRODUCTION The goal of this programming assignment is for students to write a Python program...
1. INTRODUCTION The goal of this programming assignment is for students to write a Python program that uses repetition (i.e. “loops”) and decision structures to solve a problem. 2. PROBLEM DEFINITION  Write a Python program that performs simple math operations. It will present the user with a menu and prompt the user for an option to be selected, such as: (1) addition (2) subtraction (3) multiplication (4) division (5) quit Please select an option (1 – 5) from the...
Create a small program that contains the following. ask the user to input their name ask...
Create a small program that contains the following. ask the user to input their name ask the user to input three numbers check if their first number is between their second and third numbers
Write a c++ program that ask a user to enter his name and birthday (YYYY/MM/DD). If...
Write a c++ program that ask a user to enter his name and birthday (YYYY/MM/DD). If the age is greater than 21 print "welcome," and if the age is less than 21 print "sorry." Use input validation to make sure the birthdate was entered correctly.
Write a program that reads students’ names followed by their test scores. The program should output...
Write a program that reads students’ names followed by their test scores. The program should output each student’s name followed by the test scores and the relevant grade. It should also find and print the highest test score and the name of the students having the highest test score. Student data should be stored in a struct variable of type studentType, which has four components: studentFName and studentLName of type string, testScore of type int (testScore is between 0 and...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT