6.5k views
0 votes
Write a program that takes two ints as input from the keyboard, representing the number of hits and the number of at bats for a batter. Then calculate the batters hitting percentage and check if the hitting percentage is above .300. If it is, output that the player is eligible for the All Stars Game; otherwise, output that the player is not eligible. Maintain floating point precision when calculating the hitting percentage.

User Cortnee
by
5.2k points

1 Answer

5 votes

Answer:

void main(){

int noOfHits,atBats;

float hittingPercentage;

printf ("Enter the number of hits and the number of at bats for a batter\\");

scanf("%d%d",&noOfHits,&atBats);

hittingPercentage=(noOfHits/atBats)*100;

if(hittingPercentage>300)

printf("the player is eligible for the All Stars Game\\");

else

printf("the player is not eligible\\");

}

Step-by-step explanation:

Here we are reading values for noOfHits,atBats from the user and calculated hittingPercentage. if hittingPercentage>300 we are displaying corresponding message if it is not >300 again another message which illustrating the elogibility

User Chinyere
by
5.6k points