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

Develop a program Grades.java that collects the user's (students) name, course name, and the score for...
Develop a program Grades.java that collects the user's (students) name, course name, and the score for three quizzes. You are supposed to read this data from the keyboard using the Scanner class. Calculate the total score and the average score. Further, using the grading scale below, based on the average score computed above, your program should calculate and output a letter grade. and the range boundaries should be configured properly (i.e.: exactly 90 and above is an A, and anything...
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...
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...
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...
Please code in c# (C-Sharp) Write a program that will ask the user for their name....
Please code in c# (C-Sharp) Write a program that will ask the user for their name. If the user does not input anything, display a warning before continuing. The program will then ask the user whether they want to have an addition, subtraction, multiplication, or division problem. Once the user indicates their choice, the program will display 2 randomly generated numbers from 1 to 9 in a math problem matching the user’s choice. Example: user selects addition, the equation presented...
Write a program that does the following in order: 1. Ask user to enter a name...
Write a program that does the following in order: 1. Ask user to enter a name 2. Ask the user to enter five numbers “amount1”, “amount2”, “amount3”, “amount4”, “amount5” 3. Calculate the sum of the numbers “amount1”, “amount2”, “amount3”, “amount4”, “amount5” 4. If the sum is greater than 0, print out the sum 5. If the sum is equal to zero, print out “Your account balance is zero” 6. If the sum is less than 0, print out “Your account...
(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 program (name it firstMiddleLast _yourInitials.java (yourInitials represents your initials) that will: 1. Ask the...
Write a program (name it firstMiddleLast _yourInitials.java (yourInitials represents your initials) that will: 1. Ask the user (include appropriate dialog) to enter their: first name middle name last name save each of the above as a String variable as follows: firstName middleName lastName 2. Print to the screen the number of characters in each of the names (first, middle and last) 3. Print to the screen total number of characters in all three names. Include appropriate dialog in your output....
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...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT