Question
Project Instructions You will find detailed step-by-step instructions on downloading and installing the compiler below, but the basic steps in the project are these: Download
Project Instructions You will find detailed step-by-step instructions on downloading and installing the compiler below, but the basic steps in the project are these: Download and install MinGW compiler for C++. Compile the code file provided (GooddocsF.cpp). Test the resulting executable file (the program is designed to produce temperature conversions). Debug the program by correcting minor errors which have been deliberately placed in the temperature calculation formulas. Note: the formulas coded in the program are incorrect, not the formulas in the program documentation at the start of the program. Recompile the corrected code and retest the program. Submit the uncorrected and corrected versions of the program. Downloading and Installing the Compiler This section shows you how to install and test the C++ compiler MinGW for Windows. Open your browser and enter the URL "http://mingw.org." You should see the MinGW home page. Click the "Downloads" tab on the MinGW home page. Click the link labeled "Download mingw-get-setup.exe" by the line "Looking for the latest version?" Your download should begin in 5 seconds. If it does not, then click the link "direct link." Depending on the browser, accept the download option that runs the executable file. You may have to click "Run" again if your browser raises a security warning. Once the installer starts, click the "Install" button. Accept all defaults. MinGW should be installed into the directory C:\MinGW. This is correct. Click "Continue" to continue installation. Again, accept all defaults. The installation should now begin. You will see green progress bars and can view installation details in the installation windows. Once the installation reaches 100%, you will be able to click the "Continue" button again. At this point you can close your browser. Now you should see the graphical window "MinGW Installation Manager." At the moment, NO packages are selected. Select the following by checking the checkboxes (right-click the checkbox, then select "Mark for Installation"): mingw32-base mingw32-gcc-g++ Now click the menu item "Installation" and "Apply Changes." A new pop-up window appears with the button "Apply" (and Defer and Discard). Click Apply. It should show 0 packages will be removed, 0 packages will be upgraded, and 25 new packages will be installed. Again you will see the progress bars. The whole process takes several minutes as each package is installed. Once complete, you may close the installation window and exit the MinGW Installation Manager. Setting Up the Compiler To verify the installation, you will configure and setup MinGW, then enter and compile a test program. To set up and compile with MinGW C++ programs, you must input certain commands from the command line (DOS). In Windows, this is started from the start menu with "All Programs / Accessories / Command Prompt." You should see a command prompt window, with the folder location of \users\, where is the name you used logging into Windows. In Windows 7 you may not see the command prompt listed under "Accessories," in which case you can access it by clicking "run" in the right hand menu from the start button, then typing "cmd" in the dialog box and pressing enter. Instructions for running the command prompt window in Windows 8 may be found at: http://pcsupport.about.com/od/windows-8/a/command-prompt-windows-8.htm Once you have located the command prompt in your Windows, follow the steps below to set up the compiler. Create a working directory with the command "mkdir mingw." Note: this will be under your username as c:\users\\mingw." DO NOT try to create c:\mingw because it has already been created by the compiler installation process. Move to the working directory with the command "cd mingw." You can verify the installation directories by typing the command "dir \mingw\bin." The output should display 80 files. Using a text editor such as Notepad, enter the following C++ test program exactly as shown. Use the spacebar to create indenting spaces as shown. (Notepad can be run from the start menu with "All Programs / Accessories / Notepad.") #include // Stream declarations using namespace std; int main(void) { cout << "Hello World from MinGW C++" << endl; return 0; } When done, save the file using the menu "File / Save As" and navigate to the folder \users/yourname>\mingw to save the file as "hello.cpp." Still in Notepad, select the menu option "File / New" to open a new blank editing window. Type the following lines into the new window as shown below @echo off PATH=%PATH%;c:\mingw\bin;..\; echo %PATH% Save this file using "File / Save As" and store the file in your \users\\mingw folder as "go.bat." You may now exit Notepad. Run the batch file "go.bat" by typing "go" from the command prompt. The output will show the command path for your system. The important item to look for is the text "c:\mingw\bin;..\;" at the end of the output. THIS BATCH FILE IS RUN ONLY ONCE EACH TIME YOU OPEN A COMMAND WINDOW TO COMPILE C++ PROGRAMS. Compile the program with the command "\mingw\bin\g++ -o hello.exe hello.cpp" Test your program by typing the command "hello." You should see the output "Hello World from MinGW C++" on a new line. Your installation of MinGW C++ is complete. You may now continue with the project coding exercise. Coding, Compiling, and Debugging Compile the file "GoodDocsF.cpp" using the following command: g++ -o GoodDocsF.exe GoodDocsF.cpp Test by typing "GoodDocsF" and observe the output results, comparing them to the test case. Open the file "GoodDocsF.cpp" in your text editor and modify the formulas as required to make the output correspond to that shown in the test case. Compile the modified code and text to verify that the output now corresponds to that shown in the test case. . //: GoodDocs.cpp /* Title: GoodDocsF.cpp Description: Temperature Conversion Program Date: December 8, 2013 Author: Richard S. Huntrods Version: 1.0 Copyright: 2013 Richard S. Huntrods */ /* DOCUMENTATION Program Purpose: Demonstrate proper format for documentation, test plans and comments. Also demonstrate user prompts, keyboard input, simple calculations and output, specifically converting temperatures from F to C. Compile (assuming mingw compiler and opened command prompt): g++ -o GoodDocsF GoodDocsF.cpp Execution (in a Command Prompt window): GoodDocsF.exe (or just GoodDocsF) Classes: none Variables: input_units (char) = C or F to designate temperature units for the supplied input temperature. output_units (char) = C or F to designate temperature units desired for the output conversion, input_temp (float) = real (decimal) number supplied by user which is the input temperature. output_temp (float) = calculated output temperature in output_units as a real (decimal) number. Formulae: The formula for converting temperatures from Fahrenheit to Celcius is: T(C) = (T(F) - 32.0) * 5.0 / 9.0; The formula for converting temperatures from Celcius to Fahrenheit is: T(F) = (T(C) * 9.0 / 5.0) + 32.0 It is important to use decimal numbers especially in the division to avoid integer devision. It is also important use use the parenthesis to enforce calculation order. */ /* TEST PLAN Normal case 1: >What is the input temperature? 32 >What are the units of the input temperature (C for Celcius or F for Fahrenheit)? F >Your input temperature is 32F which is 0C. Normal case 2: >What is the input temperature? 100 >What are the units of the input temperature (C for Celcius or F for Fahrenheit)? C >Your input temperature is 100C which is 212F. Bad Data case 1 (temperature out of range): >What is the input temperature? -4000 >What are the units of the input temperature (C for Celcius or F for Fahrenheit)? C >Your input temperature is -4000C which is out of range (less than -273.15C or -416F).. Bad Data case 2 (incorrect units): >What is the input temperature? -40 >What are the units of the input temperature (C for Celcius or F for Fahrenheit)? Q >The units you have specified are not one of C (Celcius) or F (Fahrenheit). Discussion: The program accepts any integer or decimal input temperature and a unit character which must be either C, c, F or f. The program then prints the input temperature as well as the temperature converted into the non-input units. Temperature range is from -273C (-415F) to any positive number. */ #include // Stream declarations using namespace std; int main(void) { char input_units, output_units; float input_temp, output_temp; int error = 0; // request and obtain name cout << "What is the input temperature? "; cin >> input_temp; // request and obtain age cout << "What are the units of the input temperature (C for Celcius or F for Fahrenheit)? "; cin >> input_units; // convert input units to upper case input_units = toupper(input_units); // check input_units for acceptable response; perform appropriate conversion if acceptable and print error message if not if(input_units == 'C') { // display input cout << "Your input temperature is " << input_temp << input_units; // range check input_temp if(input_temp < -273) { // disply out of range error message cout << " which is out of range (less than -273C or -416F)." << endl; } else { // convert from Celcius to Fahrenheit output_units = 'F'; output_temp = (input_temp * 9.0) / (5.0 + 32.0); // display converted output cout << " which is " << output_temp << output_units << "." << endl; } } else if(input_units == 'F') { // display input cout << "Your input temperature is " << input_temp << input_units; // range check input_temp if(input_temp < -416) { // out of range cout << " which is out of range (less than -273C or -416F)." << endl; } else { // convert from Fahrenheit to Celcius output_units = 'C'; output_temp = (input_temp - 32.0 * 5.0) / 9.0; // display converted output cout << " which is " << output_temp << output_units << "." << endl; } } else { // display input_unit error message cout << "The units you have specified are not one of C (Celcius) or F (Fahrenheit)" << endl; } } ///:~
//: GoodDocs.cpp /* Title: GoodDocsF.cpp Description: Temperature Conversion Program Date: December 8, 2013 Author: Richard S. Huntrods Version: 1.0 Copyright: 2013 Richard S. Huntrods */ /* DOCUMENTATION Program Purpose: Demonstrate proper format for documentation, test plans and comments. Also demonstrate user prompts, keyboard input, simple calculations and output, specifically converting temperatures from F to C. Compile (assuming mingw compiler and opened command prompt): g++ -o GoodDocsF GoodDocsF.cpp Execution (in a Command Prompt window): GoodDocsF.exe (or just GoodDocsF) Classes: none Variables: input_units (char) = C or F to designate temperature units for the supplied input temperature. output_units (char) = C or F to designate temperature units desired for the output conversion, input_temp (float) = real (decimal) number supplied by user which is the input temperature. output_temp (float) = calculated output temperature in output_units as a real (decimal) number. Formulae: The formula for converting temperatures from Fahrenheit to Celcius is: T(C) = (T(F) - 32.0) * 5.0 / 9.0; The formula for converting temperatures from Celcius to Fahrenheit is: T(F) = (T(C) * 9.0 / 5.0) + 32.0 It is important to use decimal numbers especially in the division to avoid integer devision. It is also important use use the parenthesis to enforce calculation order. */ /* TEST PLAN Normal case 1: >What is the input temperature? 32 >What are the units of the input temperature (C for Celcius or F for Fahrenheit)? F >Your input temperature is 32F which is 0C. Normal case 2: >What is the input temperature? 100 >What are the units of the input temperature (C for Celcius or F for Fahrenheit)? C >Your input temperature is 100C which is 212F. Bad Data case 1 (temperature out of range): >What is the input temperature? -4000 >What are the units of the input temperature (C for Celcius or F for Fahrenheit)? C >Your input temperature is -4000C which is out of range (less than -273.15C or -416F).. Bad Data case 2 (incorrect units): >What is the input temperature? -40 >What are the units of the input temperature (C for Celcius or F for Fahrenheit)? Q >The units you have specified are not one of C (Celcius) or F (Fahrenheit). Discussion: The program accepts any integer or decimal input temperature and a unit character which must be either C, c, F or f. The program then prints the input temperature as well as the temperature converted into the non-input units. Temperature range is from -273C (-415F) to any positive number. */ #include// Stream declarations using namespace std; int main(void) { char input_units, output_units; float input_temp, output_temp; int error = 0; // request and obtain name cout << "What is the input temperature? "; cin >> input_temp; // request and obtain age cout << "What are the units of the input temperature (C for Celcius or F for Fahrenheit)? "; cin >> input_units; // convert input units to upper case input_units = toupper(input_units); // check input_units for acceptable response; perform appropriate conversion if acceptable and print error message if not if(input_units == 'C') { // display input cout << "Your input temperature is " << input_temp << input_units; // range check input_temp if(input_temp < -273) { // disply out of range error message cout << " which is out of range (less than -273C or -416F)." << endl; } else { // convert from Celcius to Fahrenheit output_units = 'F'; output_temp = (input_temp * 9.0) / (5.0 + 32.0); // display converted output cout << " which is " << output_temp << output_units << "." << endl; } } else if(input_units == 'F') { // display input cout << "Your input temperature is " << input_temp << input_units; // range check input_temp if(input_temp < -416) { // out of range cout << " which is out of range (less than -273C or -416F)." << endl; } else { // convert from Fahrenheit to Celcius output_units = 'C'; output_temp = (input_temp - 32.0 * 5.0) / 9.0; // display converted output cout << " which is " << output_temp << output_units << "." << endl; } } else { // display input_unit error message cout << "The units you have specified are not one of C (Celcius) or F (Fahrenheit)" << endl; } } ///:~
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started