Define doubles named celsius and fahrenheit BEFORE the loop and set each to zero
ID: 3757631 • Letter: D
Question
Define doubles named celsius and fahrenheit BEFORE the loop and set each to zero. Use a WHILE loop to iterate through the celsius values. Check to see if celsius is <=20 each time you loop. Make sure to increment celsius EACH TIME you loop Make sure you figure out the new Fahrenheit value EACH TIME you loop Use a System.out.printf statement (from Chapter 3.10) to format and display the Celsius and Fahrenheit equivalents EACH TIME you loop Format the results so one decimal point appears at the end of the Fahrenheit numbers, and no decimal point appears at the end of the Celsius numbers.See Chapter 3.10 Here's what your output should look like: CELSIUS: 0 FAHRENHEIT: 32.0 CELSIUS: 1 FAHRENHEIT: 33.8 CELSIUS: 2 FAHRENHEIT: 35.6 CELSIUS: 3 FAHRENHEIT: 37.4 CELSIUS: 4 FAHRENHEIT: 39.2 CELSIUS: 5 FAHRENHEIT: 41.0 CELSIUS: 6 FAHRENHEIT: 42.8 CELSIUS: 7 FAHRENHEIT: 44.6 CELSIUS: 8 FAHRENHEIT: 46.4 CELSIUS: 9 FAHRENHEIT: 48.2 CELSIUS: 10 FAHRENHEIT: 50.0 CELSIUS: 11 FAHRENHEIT: 51.8 CELSIUS: 12 FAHRENHEIT: 53.6 CELSIUS: 13 FAHRENHEIT: 55.4 CELSIUS: 14 FAHRENHEIT: 57.2 CELSIUS: 15 FAHRENHEIT: 59.0 CELSIUS: 16 FAHRENHEIT: 60.8 CELSIUS: 17 FAHRENHEIT: 62.6 CELSIUS: 18 FAHRENHEIT: 64.4 CELSIUS: 19 FAHRENHEIT: 66.2 CELSIUS: 20 FAHRENHEIT: 68.0 Not only must your program meet the requirements of the problem,you must also: Include your name and the program's purpose in a comment that appears before the class declaration. Follow the naming guidelines for classes. Your code should be "neat" with the main method indented within the class and the statements in the body of the main method indented within the main method. You must ATTACH the .java file before submitting the assignment.
Explanation / Answer
class cel_fer
{
public static void main(String args[])
{
int c=1,i;
double f;
while(c<=20)
{
f= c*(9.0/5.0)+32;
System.out.println("CELSIUS: " + c +" FAHRENHEIT: "+f);
c++;
}
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.