Question

in Java,

temperature problem Create a package named temperature and create a program that has a while loop. • • Inside the while loop,

0 0
Add a comment Improve this question Transcribed image text
Answer #1
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        double totalF = 0, totalC = 0, count = 0, c, f;
        while (true) {
            System.out.print("Enter Temp in Centigrade or <= -100.0 to quit: ");
            c = in.nextDouble();
            if (c <= -100)
                break;
            f = (c * 1.8) + 32;
            totalC += c;
            totalF += f;
            System.out.println("Temperature: F(" + f + ") C(" + c + ")");
            ++count;
        }
        System.out.println("\nAverage: Centigrade(" + (totalC / count) + ") Average: Fahrenheit(" + (totalF / count) + ")");
    }
}

Add a comment
Know the answer?
Add Answer to:
in Java, temperature problem Create a package named temperature and create a program that has a...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • In Java. I am getting confused with this assignment, my confusion starts where I stopped. Create a package named tempera...

    In Java. I am getting confused with this assignment, my confusion starts where I stopped. Create a package named temperature and create a program that has a while loop. • Inside the while loop, your program will prompt the user for temperature in Centigrade. • If the Centigrade value read in is <= -100, the loop will exit. • Otherwise, your program will compute the Fahrenheit equivalent temperature. • Inside the while loop, your program will print out the Centigrade...

  • Temperature Converter Create a temperature conversion program that will convert the following to Fahrenheit: Celsius Kelvin...

    Temperature Converter Create a temperature conversion program that will convert the following to Fahrenheit: Celsius Kelvin Newton Your program should take a character which represents the temperature to convert from and a value to be converted to using the following specification: C - Celsius K - Kelvin N - Newton In addition your program should take in the following character to exit the program: X - eXit the program The numeric input for your program should be of type double....

  • Write a Java program that converts Centigrade temperatures to Fahrenheit temperatures. The formula is F =...

    Write a Java program that converts Centigrade temperatures to Fahrenheit temperatures. The formula is F = 9/5C + 32 F is the Fahrenheit temperature and C is the centigrade temperature.

  • Intro To Java Class. AS SIMPLE AS POSSIBLE. Please post the pic of code, will up...

    Intro To Java Class. AS SIMPLE AS POSSIBLE. Please post the pic of code, will up Vote! You will need to use Blue) for the following questions. Although these are programming exercises, remember always that the first step to the program is to put your ideas on paper to organize your thoughts. Remember Section 1.6: The Programming Process. Centigrade to Fahrenheit Table Write a program that displays a table of the centigrade temperatures 0 through 20 and their Fahrenheit equivalents....

  • assignment 1 Make sure you are able to write a python program as described in the...

    assignment 1 Make sure you are able to write a python program as described in the text. You will be working in repl.it Title your program temperature. Add a comment to say that this program converts Fahrenheit to Centigrade. Create variables: fahrenheit and centigrade values my name Have the program prompt the user (the instructor) for a value for the fahrenheit variable. Convert the value to centigrade, using this formula: (fahrenheit - 32) * ÷ 9 = centigrade Have the...

  • Create a program using MIPS that does the following: The program will do the following: Prompt...

    Create a program using MIPS that does the following: The program will do the following: Prompt the user to enter a letter indicating Celsius or Fahrenheit C or c indicates that temperature entered is in Celsius. F or f indicates that temperature entered is in Fahrenheit. If the letter entered is not C, c, F, or f, print out error message "Wrong Letter!". Prompt the user to enter an integer indicating the temperature matching the letter just entered. Convert the...

  • Create a program in Python that will allow the user to enter a temperature in Fahrenheit...

    Create a program in Python that will allow the user to enter a temperature in Fahrenheit which will then be converted to degrees Celsius. The program will keep asking the user for a Fahrenheit temperature until the user enters Q to quit. After each conversion the program needs to print out the degrees Celsius. The input prompts for this problem need to look like the following: Degrees Fahrenheit: Continue: For these input prompts watch the capitalization and spacing. There are...

  • python Write a program that displays a table of Celsius temperatures and equivalent Fahrenheit temperatures. You...

    python Write a program that displays a table of Celsius temperatures and equivalent Fahrenheit temperatures. You can find the formula online if necessary. Your program should print both scales accurate to one decimal place in columns 8 characters wide (see page 71). Use Celsius temperatures ranging from -40C to 40C in 10 degree increments. See Required Output. Required Output CEL FAH === -40.0 -40.0 -30.0 -22.0 -20.0 -4.0 - 10.0 14.0 0.0 32.0 10.0 50.0 20.0 68.0 30.0 86.0 40.0...

  • Write a C++ program that prompts a user to enter a temperature in Fahrenheit as a...

    Write a C++ program that prompts a user to enter a temperature in Fahrenheit as a real number. After the temperature is entered display the temperature in Celsius. Your program will then prompt the user if they want to continue. If the character n or N is entered the program will stop; otherwise, the program will continue. After your program stops accepting temperatures display the average of all the temperatures entered in both Fahrenheit and Celsius. Be sure to use...

  • write program in java 5. Falling Distance When an object is falling because of gravity, the...

    write program in java 5. Falling Distance When an object is falling because of gravity, the following formula can be used to determine the distance the object falls in a specific time period: d = 1/2 gta The variables in the formula are as follows: d is the distance in meters, g is 9.8, and t is the amount of time, in seconds, that the object has been falling. Write a method named fallingDistance that accepts an object's falling time...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT