CIS 215 Class 7 – Practice with Functions One of the standard assignments in computer programming requires students to write a program that will convert Celsius temperatures to Fahrenheit or the other...

Please review attached pdf and advise on a quote to complete.




CIS 215 Class 7 – Practice with Functions One of the standard assignments in computer programming requires students to write a program that will convert Celsius temperatures to Fahrenheit or the other way around. I think we can do better than that. You will write a C++ program that will request the user to input a numeric value for a temperature and a char to indicate which scale the temperature is recorded in (C for Celsius or F for Fahrenheit). The code will then call a function named ConvertTemp, passing in as arguments the numeric value and the char. The ConvertTemp method will determine if the conversion is from Celsius to Fahrenheit or Fahrenheit to Celsius, make the appropriate conversion, and return the converted value. Finally, in the main method, the application will output to the screen the new temperature and the appropriate char. The output of your program should look more or less like this. Some comments: To make your task a little simpler I have posted some code (below) that will help you with the import from the keyboard Note that the ConvertTemp method has two parameters, but of course can return only one. I will leave it to you to find the conversion formulas and convert them to C++ code. By now you should be able to write C++ code that is simple, clear, and follows the guidelines expressed in the textbook and discussed in our class meetings. I expect your code to be neat, well organized, and easy to read. The output to the screen will be well organized. Your file will, of course, begin with the standard comment block that you have been using since the start of this course. NOTE: You will use only C++ code for which examples have been demonstrated in the textbook thus far or discussed in the on-line class meetings. This assignment is due not later than the end of the day, Monday, July 6. Put your source code (TempConverter.cpp) for this project in a zip folder named Wk7YourLastName.zip. Upload the zip folder to the appropriate link on the BrightSpace Assignments page. /* Too many questions keep popping up with the same problem. How do I get user input from cin using >> into X type? Using the >> operator opens you up to a lot of problems. Just try entering some invalid data and see how it handles it. cin is notorious for causing input issues because it doesn't remove the newline character from the stream or do type-checking. So anyone using cin >> var; and following it up with another cin >> stringtype; or getline(); will receive empty inputs. It's best practice to NOT MIX the different types of input methods from cin. I know it's going to be easier to use cin >> integer; than the code below. However, the code below is type-safe and if you enter something that isn't an integer it will handle it. The above code will simply go into an infinite loop and cause undefined behavior in your application. Another disadvantage of using cin >> stringvar; is that cin will do no checks for length and it will break on a space. So you enter something that is more than 1 word, only the first word is going to be loaded leaving the space and following word still in the input stream. A more elegant solution and much easier to use is the getline(); function. The example below shows you how to load information and convert it between types. */ #include #include #include using namespace std; int main() { string input = ""; cout < "how="" to="" get="" a="" string/sentence="" with="" spaces"="">< endl;="" cout="">< "please="" enter="" a="" valid="" sentence="" (with="" spaces):\n";="" getline(cin,="" input);="" cout="">< "you="" entered:="" "="">< input="">< endl="">< endl;="" cout="">< "how="" to="" get="" a="" number"="">< endl;="" int="" mynumber="0;" while(true)="" {="" cout="">< "please="" enter="" a="" valid="" number:="" ";="" getline(cin,="" input);="" this="" code="" converts="" from="" string="" to="" number="" safely.="" stringstream="" mystream(input);="" if(mystream="">> myNumber) { break; // stop the while loop } cout < "invalid="" number,="" please="" try="" again"="">< endl;="" }="" end="" of="" while="" loop="" cout="">< "you="" entered:="" "="">< mynumber="">< endl="">< endl;="" cout="">< "how="" to="" get="" a="" char"="">< endl;="" char="" mychar="{0};" while(true)="" {="" cout="">< "please="" enter="" 1="" char:="" ";="" getline(cin,="" input);="" if="" (input.length()="=" 1)="" {="" mychar="input[0];" break;="" }="" cout="">< "invalid="" character,="" please="" try="" again"="">< endl;="" }="" cout="">< "you="" entered:="" "="">< mychar="">< endl="">< endl;="" cout="">< "all="" done.="" and="" without="" using="" the="">> operator" < endl; return 0; } endl;="" return="" 0;="">
Jun 30, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here