In: Computer Science
Using C Programming. Put all of these 4 things in one source file and attach to this question. Put #1 in main. Put all the others into separate function functions but in the same file.
1)
Put this code in main.
You are writing a program for Bowl Me Over, a local bowling alley. The program will allow staff to enter any number of bowling scores. Scores in a standard game range between 0 to 300, with being a perfect score. Get scores from the user as integers. Continue to get scores until the user enters a value outside of the acceptable score range. As soon as a value outside of this range is entered, output information as show below.
For a perfect score, you must not to use arrays and you must only include 1 loop to do this processing. Only use concepts and code we have covered.
Examples below, user input is italicized:
Bowling score: 2
Bowling score: 207
Bowling score: 200
Bowling score: 301
Top score: 207
Average score: 136.3333
Elite bowlers (scores above 200): 1
Beginners (scores below 100): 1
Hints: not concerned about formatting the average to 2 decimal places as long as it is a double number
2)
Given a function header:
int verify(int arg1, char argChar)
write a function that will return 21 only if arg1 is positive and argChar is a lower case vowel (a, e, i, o, or u). Otherwise, return -1.
3)
Write a function that will return the 4th root of a double number passed as a parameter. Name the function fourthRoot(). Hints, the 4th root of 16 is 2 (2 * 2 *2 *2 =16). x 1/r = r root of x.
#include <stdio.h>
#include <math.h>
int verify(int arg1, char argChar)
{
if(arg1>0&&(argChar=='a'||argChar=='e'||argChar=='i'||argChar=='o'||argChar=='u'))
return 21;
return -1;
}
double fourthRoot(double n)
{
return pow(n,0.25);
}
int main()
{
double average,score,top=-1;
int count=0,elite=0,beginner=0;
printf("Bowling score: ");
scanf("%lf",&score);
while(score>=0&&score<=300)
{
if(score<100)
beginner++;
if(score>200)
elite++;
count++;
average+=score;
if(score>top)
top=score;
printf("Bowling score: ");
scanf("%lf",&score);
}
printf("Top score: %lf\n",top);
printf("Average score: %f\n",(average/count));
printf("Elite bowlers (scores above 200): %d\n",elite);
printf("Beginners (scores below 100): %d\n",beginner);
printf("verify(2,'a') = %d\n",verify(2,'a'));
printf("verify(-1,'a') = %d\n",verify(-1,'a'));
printf("verify(2,'A') = %d\n",verify(2,'A'));
printf("Fourth root of 16 = %lf\n",fourthRoot(16));
printf("Fourth root of 21 = %lf",fourthRoot(21));
return 0;
}