You are the official score keeper for the \"C\" Bowling Association (CBA). You s
ID: 3532841 • Letter: Y
Question
You are the official score keeper for the "C" Bowling Association (CBA). You should write a program that will:
? a. Input date of game (three integers yyyy/mm/dd).
? b. Input bowler's first and last name initial (two separate characters) and three scores (three
integer of 0-300 ranges).
? c. Calculate average for that bowler.
? d. Assign stars to that bowler based on the following scale:
o Avg >= 200
o Avg 170 to 199 o Avg 125 to 169 o Avg 100 to 124 o Avg < 100
4 stars 3 stars 2 stars 1 star no star
? e. Output the bowlers name, avg, and number of stars earned.
? f. Your program must be able to process any number of bowlers.
? g. Discover which bowler had the highest average and print out his/her name, average and
number of stars. (Assume there is only one bowler who had the highest average)
? h. Calculate and output the average of all the bowlers and the date of game.
Hint and requirement:
? Use scanf("%d/%d/%d", &y, &m, &d); to read yyyy/mm/dd. Use scanf("%*c%c%c", &fi, &li); to read first and last initials after reading date with scanf(); If there is no other scanf() used before the one you use to read first/last initials, you can just use the normal scanf("%c%c", &fi, &li);
? No array is allowed to use in this program.
? Assume input is reasonable and without error.
Implement all functionalities in your main() function and name this file as c.1.c. Example:
This is the "C" bowling association
Please input the game date(yyyy/mm/dd):2012/10/14 Please input the bowler's first and last initial:bo Please input the bowler's score:101 102 103
Bowler b. o. has average 102 and 1 star(s)
Modify c.1.c to create a new file with name c.2.c. In c.2.c, you need to make following changes:
? i. Instead of output the number of stars in e. and g., your program must print the actual appropriate sequence of stars (like "****"), not just a number.
? j. Step c., d. and e. in previous requirements must be written as separate functions. (e.x. int average(int, int, int); int assignStar(int); void output(char, char, int, int);)
? k. Your program should be able to process multiple games in different dates. And it should discover the bowler who had the highest average over these games and print out his/her name, average and assigned sequence of stars. Your program should also print the date when the best bowler had the highest score.
Example:
2012/10/13
mr
Please input the game date(yyyy/mm/dd):2012/10/14 Please input the bowler's first and last initial:bo Please input the bowler's score:101 102 103
Bowler b. o. has average 102 and *
For c.1.c:
- Input / output date incorrectly or missing: - 3 pts
- Input / output first/last initials and scores/average incorrectly: - 3 pts/each
- Assigned number of stars incorrectly: - 3 pts
- Couldn't process multiple input: -5 pts
- Best bowler information incorrect: - 5 pts
- Average over all bowlers incorrect: - 4 pts
- Use array: - 10 pts
For c.2.c:
- Sequence of stars incorrect: -3 pts
- Missing functions or didn't implement b, c, d as separate functions: - 5 pts/each
- Couldn't process multiple games: - 5 pts
- Information of best bowler in all games incorrect: - 3 pts
- Date of highest score incorrect: - 3 pts
- If any of previous requirements in b.1.c is violated, points will be taken off accordingly
Explanation / Answer
#include <stdio.h>
int main()
{
int y,m,d,s1,s2,s3,n=0;
char fi,li,hfi,hli;
int avg,havg=0,allavg=0;
int star,hstar;
printf(" This is the 'C' bowling association Please input the game date(yyyy/mm/dd):");
scanf("%d/%d/%d", &y, &m, &d);
printf("Please input the bowler's first and last initial:");
scanf("%*c%c%c", &fi, &li);
while( fi != '^' && li != 'D' )
{
printf("Please input the bowler's score:");
scanf("%d %d %d", &s1, &s2, &s3);
avg = (s1+s2+s3)/3;
allavg+=avg;
n++;
if(avg>=200) { star =4; }
else if( avg>=170 && avg<=199 ) { star =3; }
else if( avg>=125 && avg<=169 ) { star =2; }
else if( avg>=100 && avg<=124 ) { star =2; }
else if( avg<100 ) { star =1; }
if( avg > havg )
{ havg=avg; hfi=fi; hli=li; hstar=star;}
printf("Bowler %c. %c. has average %d and %d star(s) ",fi,li,avg,star);
printf("Please input the bowler's first and last initial:");
scanf("%c%c", &fi, &li);
}
allavg/=n;
printf("The best bowler on %d/%d/%d is: ", y, m, d );
printf("Bowler %c. %c. has average %d and %d star(s) ",hfi,hli,havg,hstar);
printf("The average of all bowlers in this game is %d ",allavg);
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.