Task 2-High jump-the solution
First you need to enter the values of x and y which represent the value of the third jump of the first and the third jump of the third competitor, respectively. It is first necessary to determine the best jump per competitor. For the first competitor, the "x" value should be compared with 5.94, and the value of 5.87 will certainly not be the best jump because 5.94> 5.87. The if-else command should be used for this.
As for the second competitor, his best jump is 5.89.
The best jump of the third competitor is determined using a similar to the first, using the if - else command, where the value of "y" is compared with 5.87.
Finally, the best jumps of the competitors are compared using the if-else if-else if command. The maximum value should be determined.
It should be noted that cases where the first and second contestant share first place and all three contestants share first place will never happen, so they can essentially be kicked out of the last if-else if ... command.
As for the second competitor, his best jump is 5.89.
The best jump of the third competitor is determined using a similar to the first, using the if - else command, where the value of "y" is compared with 5.87.
Finally, the best jumps of the competitors are compared using the if-else if-else if command. The maximum value should be determined.
It should be noted that cases where the first and second contestant share first place and all three contestants share first place will never happen, so they can essentially be kicked out of the last if-else if ... command.
#include <stdio.h>
#include <stdlib.h>
int main()
{
double x,y,takm1Max,takm2Max,takm3Max,bestJump;
printf("Enter the third jump of the first and third contestant\n");
scanf("%lf%lf",&x,&y);
if(x>5.94)
takm1Max=x;
else
takm1Max=5.94;
takm2Max=5.89;
if(x>5.87)
takm3Max=y;
else
takm3Max=5.87;
/*The best jump is the largest value between takm1Max, takm2Max, takm2Max*/
if(takm1Max>takm2Max && takm1Max>takm3Max)
{
bestJump=takm1Max;
printf("The first competitor won with a jump of %.2f m\n",bestJump);
}
else if(takm2Max>takm1Max && takm2Max>takm3Max)
{
bestJump=takm2Max;
printf("The second competitor won with a jump of %.2f m\n",bestJump);
}
else if(takm3Max>takm1Max && takm3Max>takm2Max)
{
bestJump=takm3Max;
printf("The third contestant won with a jump of %.2f m\n",bestJump);
}
/*The best jump has been determined, but there is still the possibility that two or three competitors have the same jump value*/
else if(takm1Max==takm2Max && takm1Max>takm3Max){
bestJump=takm1Max;
printf("The first and second competitors share the first place with a jump of %.2f m\n",bestJump);
}
else if(takm1Max==takm3Max && takm1Max>takm2Max){
bestJump=takm1Max;
printf("The first and third competitors share the first place with a jump of %.2f m\n",bestJump);
}
else if(takm2Max==takm3Max && takm2Max>takm1Max){
bestJump=takm1Max;
printf("The second and third competitors share the first place with a jump of %.2f m\n",najboljiSkok);
}
else if(takm1Max==takm2Max && takm1Max==takm3Max){
bestJump=takm1Max;
printf("All three competitors share first place with a jump of %.2f m\n",bestJump);
}
return 0;
}
#include <stdlib.h>
int main()
{
double x,y,takm1Max,takm2Max,takm3Max,bestJump;
printf("Enter the third jump of the first and third contestant\n");
scanf("%lf%lf",&x,&y);
if(x>5.94)
takm1Max=x;
else
takm1Max=5.94;
takm2Max=5.89;
if(x>5.87)
takm3Max=y;
else
takm3Max=5.87;
/*The best jump is the largest value between takm1Max, takm2Max, takm2Max*/
if(takm1Max>takm2Max && takm1Max>takm3Max)
{
bestJump=takm1Max;
printf("The first competitor won with a jump of %.2f m\n",bestJump);
}
else if(takm2Max>takm1Max && takm2Max>takm3Max)
{
bestJump=takm2Max;
printf("The second competitor won with a jump of %.2f m\n",bestJump);
}
else if(takm3Max>takm1Max && takm3Max>takm2Max)
{
bestJump=takm3Max;
printf("The third contestant won with a jump of %.2f m\n",bestJump);
}
/*The best jump has been determined, but there is still the possibility that two or three competitors have the same jump value*/
else if(takm1Max==takm2Max && takm1Max>takm3Max){
bestJump=takm1Max;
printf("The first and second competitors share the first place with a jump of %.2f m\n",bestJump);
}
else if(takm1Max==takm3Max && takm1Max>takm2Max){
bestJump=takm1Max;
printf("The first and third competitors share the first place with a jump of %.2f m\n",bestJump);
}
else if(takm2Max==takm3Max && takm2Max>takm1Max){
bestJump=takm1Max;
printf("The second and third competitors share the first place with a jump of %.2f m\n",najboljiSkok);
}
else if(takm1Max==takm2Max && takm1Max==takm3Max){
bestJump=takm1Max;
printf("All three competitors share first place with a jump of %.2f m\n",bestJump);
}
return 0;
}