Ask Question
14 May, 19:41

Create an algorithm that will prompt a user to answer the following question. "Do you want to convert the Fahrenheit temperature to Celsius?' While the user answers yes, the algorithm will prompt a user for a Fahrenheit temperature, convert the Fahrenheit temperature to Celsius, and print the Celsius temperature. Write the algorithm using pseudocode, and create a desk check using at least one set of test data. The formula used to convert Fahrenheit to Celsius is: °C = (°F - 32) / 1.8 Example: 68 °F Celsius = (68-32) / 1.8 Celsius = (36) / 1.8 Celsius = 20

+2
Answers (1)
  1. 14 May, 22:36
    0
    Algorithm to convert temperature from Fahrenheit to Celsius:

    1. declare variables "C" to store temperature in Celsius and "F" to

    store the temperature in Fahrenheit.

    2. Ask from user "Do you want to convert the Fahrenheit temperature to Celsius?'

    3. if user input is "yes":

    3.1. prompt user to enter the temperature in Fahrenheit

    3.2. read the temperature in Fahrenheit and assign it variable "F"

    4. Calculate the temperature in Celsius as C = (°F - 32) / 1.8

    5. Print the temperature in Celsius to user

    6. End the program.

    Here is code in java.

    import java. util.*;

    class Main

    {

    public static void main (String[] args) throws java. lang. Exception

    {

    try{

    double C, F;

    String user_choice;

    //scanner class object to read the input

    Scanner scr=new Scanner (System. in);

    System. out. print ("Do you want to convert the Fahrenheit temperature toCelsius?:");

    / / read the choice of user

    user_choice = scr. nextLine ();

    if (user_choice. equals ("yes"))

    {

    System. out. print ("enter the temperature in Fahrenheit:");

    / / read the temperature in Fahrenheit

    F = scr. nextDouble ();

    / / calculate the temperature in Celsius

    C = (F-32) / 1.8;

    / / print the temperature in Celsius

    System. out. println ("Corresponding temperature in Celsius is: "+C);

    }

    }catch (Exception ex) {

    return; }

    }

    }

    Explanation:

    Read the choice of user. If the user_choice is equal to "yes", then read the temperature in Fahrenheit and calculate Corresponding temperature in Celsius as "C = (°F - 32) / 1.8". Print the temperature in Celsius.

    Output:

    Do you want to convert the Fahrenheit temperature toCelsius?:yes

    enter the temperature in Fahrenheit:68

    Corresponding temperature in Celsius is: 20.0
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Create an algorithm that will prompt a user to answer the following question. "Do you want to convert the Fahrenheit temperature to ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers