Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Program written earlier: using System; namespace SimpleTempConversion { public class FahrenheitToCelsius { public static void Main() { double F;// Declare a variable to hold the

Program written earlier:

using System;

namespace SimpleTempConversion { public class FahrenheitToCelsius { public static void Main() { double F;// Declare a variable to hold the temperature obtained from the user double C;// Declare a variable to hold the converted temperature Console.WriteLine("What is the temperature (in degrees Fahrenheit): ");// Display "What is the temperature (in degrees Fahrenheit): " // ...

// Read the current Fahrenheit temperature from the user F=Convert.ToDouble(Console.ReadLine());

// Convert the Fahrenheit temperature into degrees Celsius C=(F-32)/1.8;

// Display "The temperature is (temperature here) degrees Celsius" Console.WriteLine("The temperature is {0} degrees Celsius",C);

// Prompt the user to press enter to close the window Console.WriteLine("Press enter to exit."); Console.ReadLine(); } } }

image text in transcribed

FRAMEWORK/HINTS:

using System; namespace SimpleTempConversion { public class FahrenheitToCelsiusV2 { public static void Main() { // Declare a variable of type 'double' to hold the temperature obtained from the user // ... // Declare a variable of type 'double' to hold the converted temperature // ... // Declare a bool to record if the user has entered in a valid number yet // ... do { // Display "What is the temperature (in degrees Fahrenheit): " // ... // Use TryParse() to read the Fahrenheit temperature. Set the bool variable // declared earlier to the result of TryParse() // ... // Check the bool variable to see if TryParse() failed to parse // ... { // Display "Invalid input" on a line by itself. // ... } // The code should loop while the input is not valid } // ... // Convert the Fahrenheit temperature into degrees Celsius // ... // Display "The temperature is (temperature here) degrees Celsius" // Remember to replace (temperature here) with the Celsius temperature // ... // Prompt the user to press enter to close the window Console.WriteLine("Press enter to exit."); Console.ReadLine(); } } } 
Earlier, you wrote a program to take a temperature in degrees Fahrenheit and convert it to Celsius For this task you are to make this program more robust by making it check that the text entered is actually a number. If the user enters something other than a number, your program should report "Invalid input" and ask for a number again. It should continue displaying "Invalid input" until a number is entered, and then convert that temperature to Celsius hat is the tenper-ature (in degree Fahre n he it): sfhd nvalid input hat is the tenperature in degrees Fahrenheit sdafkljsad nvalid input hatis the tenperature (in degrees Fahrenheit); ;,.#ae^#& , Invalid input hat is th teperature

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

Writing a Strong Introduction

Answered: 1 week ago