Program that takes several inputs and data types and compares them. The Olympics
ID: 3665295 • Letter: P
Question
Program that takes several inputs and data types and compares them.
The Olympics will begin this summer and several countries will clamor to find out who will win the medal count. However, there are two ways of scoring the games. The first way is called the "American" method. In this method the scoring is based on the number and type of medals a country has won. Gold medals count the most, silver is used to break ties and finally bronze medals are looked at if a country has the same number of gold and silver. Several countries (who usually score fewer gold medals) use the "Canadian" method of scoring instead of the "American" method. Using the "Canadian" method the total number of overall medals ddetermines the winner of the Olympics. Write a Java program that computes the medal winner for the Olympic Games. Do the following: bullet Ask the user what scoring method they would like to use to score the Olympics (a character). bullet Prompt the user for the number of countries competing in the current Olympics. bullet Read in the country names and their medal count. bullet Print out the name of the winning country. bullet In case of a tie, print out the winning countries in input order. Error check. Output should look similar to below. Sample Runs: Please enter the scoring method. A)merican or C)anadian rightarrow a Number of countries competing? 3 Please enter country and metal count> Germany 3 2 1 Please enter country and metal count> America 2 3 1 Please enter country and metal count> Canada 1 2 4Explanation / Answer
#include <stdio.h>
int main(void)
{
int sum;
float money;
char letter;
double pi;
sum = 10; /* assign integer value */
money = 2.21; /* assign float value */
letter = ‘A’; /* assign a character value */
pi = 2.01E+6; /* assign a double value */
printf(“ value of sum = %d ”, sum);
printf(“ value of money = %f ”, money);
printf(“ value of letter = %c ”, letter);
printf(“ value of double = %e ”, pi);
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.