Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

i'm using a text editor Exercise of If-Then-Else Statment: Get a copy of the convert.cpp file by: o Entering the cp command in hercules: cp

i'm using a text editor image text in transcribed
image text in transcribed
Exercise of If-Then-Else Statment: Get a copy of the convert.cpp file by: o Entering the cp command in hercules: cp et/data/ftp/pub/class/110/ftp/cpp/if/convert.cpp convert.cpp o or, using your mouse to copy and paste the program into Nano text editor or Visual C++. This program demonstrates how to use if-else statement. Test the program with these inputs: c 100 F 32 c0 fo d0 Explain to yourself: o Why do the last three sets of the input values yield the same output? o Why isn't c the same as C? . Why would you type any number after d even though d is not a known conversion type? . You should use two if-else structures to fix the program: o One will validate the letter as soon as it is typed: If the input letter is not C, C, F, or f, output "wrong letter". then use an else to skip the rest of the program (do not ask for temperature, do not print result) Do not return early. o The other will choose what conversion to use. Make sure to treat (C 100) and (c 100) the same, and treat (F 32) and (f 32) the same; 1/1 Program Convert converts a temperature in Fahrenheit to // Celsius or a temperature in Celsius to Fahrenheit // depending on whether the user enters an F or a c.. #include using namespace std; int main() char letter; int tempIn; int tempOut; // Place to store input letter // Temperature to be converted // Converted temperature cout > letter; cout cin > tempin; if (letter - 'C') tempOut - (9* tempin / 5) + 32; else tempout - 5. (tempin - 32) / 9; cout

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

Recommended Textbook for

Probabilistic Databases

Authors: Dan Suciu, Dan Olteanu, Christopher Re, Christoph Koch

1st Edition

3031007514, 978-3031007514

More Books

Students also viewed these Databases questions