Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function gymnastics(input) {
- let country = input[0];
- let apparatus = input[1];
- let difficulty = 0;
- let performance = 0;
- switch (country) {
- case "Russia":
- if (apparatus === "ribbon") {
- difficulty = 9.100;
- performance = 9.400;
- } else if (apparatus === "hoop") {
- difficulty = 9.300;
- performance = 9.800;
- } else {
- difficulty = 9.600;
- performance = 9.000;
- }
- break;
- case "Bulgaria":
- if (apparatus === "ribbon") {
- difficulty = 9.600;
- performance = 9.400;
- } else if (apparatus === "hoop") {
- difficulty = 9.550;
- performance = 9.750;
- } else {
- difficulty = 9.500;
- performance = 9.400;
- }
- break;
- case "Italy":
- if (apparatus === "ribbon") {
- difficulty = 9.200;
- performance = 9.500;
- } else if (apparatus === "hoop") {
- difficulty = 9.450;
- performance = 9.350;
- } else {
- difficulty = 9.700;
- performance = 9.150;
- }
- break;
- }
- let totalRating = difficulty + performance;
- let maximumPoints = 20;
- let percentageNeeded = (maximumPoints - totalRating) * 100 / 20;
- console.log(`The team of ${country} get ${totalRating.toFixed(3)} on ${apparatus}.`);
- console.log(`${percentageNeeded.toFixed(2)}%`);
- }
Advertisement
Add Comment
Please, Sign In to add comment