(Solved): Perform Temperature Conversion In An Ask-before-iterating Loop: Repeat Chapter 3 Practice Program 5 ...
Perform temperature conversion in an ask-before-iterating loop: Repeat Chapter 3 Practice Program 5 that allows a user to convert temperatures. In an outer loop, prompt for a (double) temperature value and then prompt for C/c or F/f for the type of temperature, Celsius or Fahrenheit, using Scanner method next(); if they enter something else, loop until they enter one of those values (a nested inner validation loop!), but do not ask them to repeat entering the temperature value. See last Thursdayâ€™s do-while loop info. Once you know the type, use if/else or switch statements to convert it to the other type and print the result, using these formulas: C = 5*(F â€“ 32) / 9 and F = (9*C/5) + 32. This is similar to the dollars to euros example in Week 3. After printing the converted output, ask the user to type Q/q to quit, or to press any other key to repeat the outer loop and perform another conversion (itâ€™s OK to use break; to end the outer loop if they type Q/q). try not to import java.util
Buy This Answer $6
-- OR --
Subscribe $20 / Month