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 program that prints a custom conversion table from Celsius temperatures to Fahrenheit and Newton...
Write a program that prints a custom conversion table from Celsius temperatures to Fahrenheit and Newton (Links to an external site.) temperatures. The formula for the conversion from Celsius to Fahrenheit is : F=9/5*C+32 F is the Fahrenheit temperature, and C is the Celsius temperature. The formula for the conversion from Celsius to Newton is C = 100/33*N N is the Newton Temperature and C is the Celsius temperature Your C++ program should prompt the user for a lower value...
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  
Write a java program called ImperialMetric that displays a conversion table for feet and inches to...
Write a java program called ImperialMetric that displays a conversion table for feet and inches to metres. The program should ask the user to enter the range of values that the table will hold. Here is an example of what should be output when the program runs: Enter the minimum number of feet (not less than 0): 5 Enter the maximum number of feet (not more than 30): 9 | | | | | | 0" 1.524 1.829 2.134 2.438...
Q#3 Write a C++ program to read 10 temperatures in Celsius and to store the temperatures...
Q#3 Write a C++ program to read 10 temperatures in Celsius and to store the temperatures in an array of integers, then it should convert the temperatures to Fahrenheit and store the new values rounded to the nearest integer in another array . The program should display both temperatures in a table form.    F = 9/5 x C + 32 where F is temp in Fahrenheit and C temperature in Celsius
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.
Write a Python program to read in the temperatures for ten consecutive days in Celsius and...
Write a Python program to read in the temperatures for ten consecutive days in Celsius and store them into an array. The entire array should then be displayed. Next each temperature in the array should be converted to Fahrenheit and the entire array should be again be displayed. The formula for converting Celsius to Fahrenheit is °F = (°C × 1.8) + 32. Finally, the number of cool, warm and hot days should be counted and the number of each...
Java Programming Write a program that displays the following pattern *                         *       &nbsp
Java Programming Write a program that displays the following pattern *                         *          *          * *          *          *          *          *          *          *          *          *          *          *          *             *          *          *          *          *                         *          *          *                                     * Printing Pattern A * ** *** **** ***** ****** ******* Printing Pattern B ******* ****** ***** **** *** ** * Printing Pattern C * ** *** **** ***** ****** *******
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT