Question

In: Computer Science

Write a JAVA program that displays a table of the Celsius temperatures and their Fahrenheit equivalents....

Write a JAVA program that displays a table of the Celsius temperatures and their Fahrenheit
equivalents.
 The formula for converting a temperature from Celsius to Fahrenheit is
F = 9/ 5 C + 32
where F → Fahrenheit temperature
C → Celsius temperature.
 Allow the user to enter the range of temperatures in Celsius to be converted into Fahrenheit.
 Your program must use a loop to display the values of the temperature conversions (see sample
output).


Sample Output:
Welcome to the Temperature Converter!! Enter the range of temperatures in Celsius to be converted into
Fahrenheit
Enter minimum temperature in Celsius:
­5
Enter maximum temperature in Celsius:
7
The corresponding Fahrenheit equivalents are:
­5.0 C 23.0 F
­4.0 C 24.8 F
­3.0 C 26.6 F
­2.0 C 28.4 F
­1.0 C 30.2 F
0.0 C 32.0 F
1.0 C 33.8 F
2.0 C 35.6 F
3.0 C 37.4 F
4.0 C 39.2 F
5.0 C 41.0 F
6.0 C 42.8 F
7.0 C 44.6 F
Goodbye!

Solutions

Expert Solution

Algorithm to display Celsius temperatures and their Fahrenheit equivalents

1.Input mintemp from user.

2.Input maxterm from user.

3.Implement a for loop from i=minterm to maxterm

    3.1) Calculate ((9*i)/5)+32 and store result in variable fah.

    3.2) Print i,fah

Java program to implement above algorithm

import java.util.*;

public class Main
{
        public static void main(String[] args) {
        
        double mintemp,maxtemp,fah;  //declaring variables
        Scanner sc=new Scanner(System.in); //calling scanner class
        
    System.out.println("Welcome to the Temperature Converter!! Enter the range of temperatures in Celsius to be converted into Fahrenheit");

    System.out.println("Enter minimum temperature in Celsius:"); 
    mintemp=sc.nextDouble(); //taking minimum temperature in Celsius
    System.out.println("Enter maximum temperature in Celsius:"); 
    maxtemp=sc.nextDouble(); //taking maximum temperature in Celsius
    double i;
    
    System.out.println("The corresponding Fahrenheit equivalents are");
    for(i=mintemp;i<=maxtemp;i++) //implementing for loop for range of temperature
    {
        fah=((9*i)/5)+32; //converting temperature into Fahrenheit
        System.out.println(i+"C "+fah+" F"); //printing Celsius temperature and converted Fahrenheit temperature
    }
    
        }
}

Output of above code is:


Related Solutions

Write a program that displays a temperature conversion table for degrees Celsius and degrees Fahrenheit. The...
Write a program that displays a temperature conversion table for degrees Celsius and degrees Fahrenheit. The table should include rows for all temperatures between 0 and 100 degrees Celsius that are multiples of 10 degrees Celsius. Include appropriate headings on your columns. The formula for converting between degrees Celsius and degrees Fahrenheit can be found on the internet. Python 3
Write a java program to convert Celsius degrees to Fahrenheit degrees the user enters degrees in...
Write a java program to convert Celsius degrees to Fahrenheit degrees the user enters degrees in Celsius and the program Coverts the input to Fahrenheit using the following formula T(°F) = T(°C) × 1.8 + 32 submit the source code Design output Load: 1. Design (Pseudocode ) 2. Source file (Java file, make sure to include comments) 3. Output file (word or pdf or jpig file)
*In C++ language please* Create a table that converts temperatures from Celsius to Fahrenheit Ask the...
*In C++ language please* Create a table that converts temperatures from Celsius to Fahrenheit Ask the user if they would like to know today's temperatures When "yes": Ask or their name -Generate a random number: use the length of their name (nameLngth) to set the seed Use the length of their name (nameLngth) as the starting point, and 99 as the ending point for a range of Celsius temperatures Output the range of Celsius temperatures alongside the Fahrenheit temperature conversions...
At what temperatures values are the following scales the same? (a) The Fahrenheit and the Celsius   ...
At what temperatures values are the following scales the same? (a) The Fahrenheit and the Celsius    (b) The Celsius and the Kelvin     (c) The Fahrenheit and the Kelvin  
Instructions Write a program in C# that converts a temperature given in Fahrenheit to Celsius. Allow...
Instructions Write a program in C# that converts a temperature given in Fahrenheit to Celsius. Allow the user to enter values for the original Fahrenheit value. Display the original temperature and the formatted converted value. Use appropriate value returning methods for entering (input), calculating, and outputting results.
URGENT!! DO THIS CODE IN JAVA Write a complete Java FX program that displays a text...
URGENT!! DO THIS CODE IN JAVA Write a complete Java FX program that displays a text label and a button.When the program begins, the label displays a 0. Then each time the button is clicked, the number increases its value by 1; that is each time the user clicks the button the label displays 1,2,3,4............and so on.
in java Write a Java Program that displays a menu with five different options: 1. Lab...
in java Write a Java Program that displays a menu with five different options: 1. Lab Test Average Calculator 2. Dice Roll 3. Circle Area Calculator 4. Compute Distance 5. Quit The program will display a menu with each of the options above, and then ask the user to enter their choice. There is also a fifth option to quit, in which case, the program will simply display a goodbye message. Based on the user’s choice, one of the options...
in java Write a program that reads in ten numbers and displays the number of distinct...
in java Write a program that reads in ten numbers and displays the number of distinct numbers and the distinct numbers separated by exactly one space (i.e., if a number appears multiple times, it is displayed only once). (Hint: Read a number and store it to an array if it is new. If the number is already in the array, ignore it.) After the input, the array contains the distinct numbers. Here is the sample run of the program: Enter...
Write in java Q 4.Centigrade and Fahrenheit are two scales to measure temperature. Write a program...
Write in java Q 4.Centigrade and Fahrenheit are two scales to measure temperature. Write a program that that prompts the user to enter Centigrate and then print the Fahrenheit. Use following formula for conversion. Fahrenheit = Centigrade*1.8 +   32 ; Q. 7 Write a program to calculate the bill of a customer. The program will -           Prompt the employee to enter the monthly plan fees. -           Prompt the employee to enter the rate per additional minute. -          Print the bill...
In Java: Write a program called F2C that allows the user to convert from degrees Fahrenheit...
In Java: Write a program called F2C that allows the user to convert from degrees Fahrenheit to degrees Celsius. The program should prompt for a temperature in Fahrenheit and output a temperature in Celsius. All calculations should be done in in ints, so be careful of truncation.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT