Have a Question ?

Home / Answered Questions / Other / perform-temperature-conversion-in-an-ask-before-iterating-loop-repeat-chapter-3-practice-program-5-t-aw755

(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

We have an Answer from Expert View Expert Answer

Expert Answer

import java.util.*; class Ch3P5{ public static void main(String[] args) { double temp, result; char type; Scanner in = new Scanner(System.in); do{
We have an Answer from Expert
Buy This Answer $5

-- OR --

Subscribe To View Unlimited Answers
Subscribe $12 / Month