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.

Respuesta :

Answer:

void main(){

int noOfHits,atBats;

float hittingPercentage;

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

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

hittingPercentage=(noOfHits/atBats)*100;

if(hittingPercentage>300)

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

else

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

}

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