tennis.c 1.35 KB
#include <stdio.h>
//This program gets the score of a tennis match and announce it as in
//the commentaries, e.g. 40-30 is forty thirty, and 40-40 is deuce, 15-0 is
// fifteen love.
int main(){
int score1, score2;
printf("Result: ");
scanf("%d-%d", &score1, &score2);
if (score1 == score2){
switch (score1) {
case 0 :
printf("Announcement: love all\n");
break;
case 1 :
printf("Announcement: fifteen all\n");
break;
case 2 :
printf("Announcement: thirty all\n");
break;
case 3 :
printf("Announcement: deuce\n");
break;
}
}
else {
switch (score1) {
case 0 :
printf("Announcement: love ");
break;
case 1 :
printf("Announcement: fifteen ");
break;
case 2 :
printf("Announcement: thirty ");
break;
case 3 :
printf("Announcement: forty ");
break;
}
switch (score2) {
case 0 :
printf("love\n");
break;
case 1 :
printf("fifteen\n");
break;
case 2 :
printf("thirty\n");
break;
case 3 :
printf("forty\n");
break;
}
}
return 0;
}