Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

develop an algorithm which includes input, process, and output sections #include #include using namespace std; int main() { int choice; //assign a boolean value true

develop an algorithm which includes input, process, and output sections

#include #include using namespace std;

int main() { int choice; //assign a boolean value true bool run=true; double starttemp, endtemp, temp_incr, temp_conv;

cout << "Choose a conversion type: " << endl; cout << " 1. Convert F to C" << endl; cout << " 2. Convert C to F" << endl; cout << " 3. Quit" << endl; cout << "What is your choice? "; cin >> choice;

// Verify input is a number within the correct range if (!cin || choice < 1 || choice > 3) { cout << "Invalid choice. Try again." << endl; return 0; } else if (choice == 3) { cout << "Thank you for using my program. Program terminated." << endl; return 0; }

cout << "Enter starting value: "; cin >> starttemp; cout << "Enter ending value: "; cin >> endtemp; cout << "Enter increment value: "; cin >> temp_incr;

// Verify input is a number if (!cin) { cout << "Invalid data type, must be a number. Program terminated." << endl; return 0; }

// Print table header if (choice == 1) { cout <<"Fahrenheit" << setw(20) << "Celsius" << endl; } else { cout << "Celsius" << setw(20) << "Fahrenheit" << endl; } // Print table rows if(choice==1) { while(starttemp>=endtemp) { //set to run to false run=false; temp_conv = (5.0/9.0)*(starttemp - 32.0); cout << fixed << setprecision(2) << starttemp << setw(20) << temp_conv << endl; starttemp=starttemp+temp_incr; } //run the below loop only if run is true while(starttemp<=endtemp && run==true) { temp_conv = (5.0/9.0)*(starttemp - 32.0); cout << fixed << setprecision(2) << starttemp << setw(20) << temp_conv << endl; starttemp=starttemp+temp_incr; } } else { while(starttemp>=endtemp) { //set to run to false run=false; temp_conv = (9.0/5.0)*starttemp + 32.0; cout << fixed << setprecision(2) << starttemp << setw(20) << temp_conv << endl; starttemp=starttemp+temp_incr; } //run the below loop only if run is true while(starttemp<=endtemp && run==true) { temp_conv = (9.0/5.0)*starttemp + 32.0; cout << fixed << setprecision(2) << starttemp << setw(20) << temp_conv << endl; starttemp=starttemp+temp_incr; } }

return 0; }

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

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2014 Nancy France September 15 19 2014 Proceedings Part I Lnai 8724

Authors: Toon Calders ,Floriana Esposito ,Eyke Hullermeier ,Rosa Meo

2014th Edition

3662448475, 978-3662448472

More Books

Students also viewed these Databases questions

Question

Explain the factors influencing wage and salary administration.

Answered: 1 week ago

Question

Examine various types of executive compensation plans.

Answered: 1 week ago

Question

1. What is the meaning and definition of banks ?

Answered: 1 week ago

Question

Explain basic guidelines for effective multicultural communication.

Answered: 1 week ago

Question

Identify communication barriers and describe ways to remove them.

Answered: 1 week ago

Question

Explain the communication process.

Answered: 1 week ago