Question: int main ( ) { float speed, time, distance; int time, minute; print f ( Enter the speed of the tennis ball in meter
int main
float speed, time, distance;
int time, minute;
print fEnter the speed of the tennis ball in meter per minute: ;
scanf f &speed;
printfEnter the number of minutes the ball has travelled: ;
scanfd &time;
distance ;
minute ;
while minute time
distance speed minute;
printfDistance travelled at minute d: f metersln", minute, distance;
minute ;
return ;
Why am i getting a Syntax Error in this code? At the beginning.
The code is for the below question:
Write a program to calculate how far a tennis ball will touch the ground. For example, if the ball
travels meters per minute for seven minutes, the distance travelled is metres.
Write a program that asks the user for the speed of a ball in meters per minute and the
number of minutes it has travelled. You should then use a while loop to display the distance
travelled for each minute. The distance ball travels can be calculated as follows: distance
speed time
Sample output:
What is the speed of the ball in in metres per minute
How many minutes has it travelled?
Hour Distance Travelled
The above task should make an appropriate use of trycatch and ensures correct inputs are processed,
and incorrect inputs are handled by using exceptions.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
