COMP 122 DeVry Week 1 iLab 1 latest

Downloading is very simple, you can download this Course here:

http://wiseamerican.us/product/comp-122-devry-week-1-ilab-1-latest/

Or

Contact us at:

SUPPORT@WISEAMERICAN.US

COMP 122 DeVry Week 1 iLab 1 Latest

COMP122

COMP 122 DeVry Week 1 iLab 1 Latest

Part 1

Introduction to Visual C++.NET (2010) IDE

Objectives

After completing this assignment, you should:

  • be able to create an empty console-mode project in VC++.NET;
  • know how to enter, compile, build, and run a C++ console-mode program;
  • know some basic components of a C++ program, such as#include;using namespace std;; int main( );return 0;; opening and closing braces, { and }; and theint data type;
  • be able to usecin andcout. for simple text and numeric input and output;
  • be able to use basic integer arithmetic operations, including modulus;
  • know that integer division truncates;
  • understand how the compiler reacts to several common syntax errors;
  • understand the process of developing a test plan, including predicted output for specific inputs (test cases);
  • know how a program reacts to division by zero;
  • know where the .exe file is stored after a successful build; and
  • know how to keep the Command Prompt window open at the end of a console-mode program.

C++ Console-Mode Program Development Procedure

Visual C++ is an IDE (Integrated Development Environment) for writing programs in C++. The object of this laboratory is to introduce you to the basic features of an IDE (source-code entry and editing, compiling, linking, and execution) and some basic C++ programming statements to do some mathematical operations and simple input/output.

WARNING: Accurate typing is the key to success here. Although the compiler is tolerant of extra “white space” (spaces, tabs, and blank lines), it is very fussy about other syntax (punctuation, keywords, variable names, upper and lower case requirements, etc.), so be sure to type in the program below exactlyas written, including case.

In addition to showing how to create and run a program in VC++.NET, this exercise discusses how to test a program, which involves selecting test inputs and predicting what output the program should generate, then observing the actual output, comparing the two, and analyzing any differences.

Open Visual C++ .NET

Open Microsoft Visual C++ 2010.NET by double-clicking on its icon.

Figure1: When you open Visual C++ .NET, it should look similar to this image.

You may find it convenient to maximize this screen if it is not already maximized.

T

using namespace std; int main(void) { int number1, //INPUT number2; cout << “Enter first number: ” << endl; cin >> number1; cout << “Enter second number: ” << endl; cin >> number2; ind link it.

A pop-up window asks if you want to re-build the project. ClickYes. You may get one more pop-up window asking if you want to overwrite the existing project. ClickYes if you get this window. If everything is OK, you will get 0 compile errors and 0 warnings.

Results of the build (compile and link) are shown here.

Figure 10: A good build will have 0 compile errors and 0 warnings.

Compiler Errors and Warnings: Debugging

If the code has any syntax errors, you will get compiler errors. If there are any compiler errors, it cannot create an executable file. You must fix all compiler errors before you can execute the program. Error messages appear in the bottom panel of the Visual C++ window. If you cannot see them, use the scrollbar on the right side of the panel. If you double-click an error message, a little arrow will appear in the left margin of the text editor window to indicate the line that may have the error. Compilers are notorious for having misleading error messages and not flagging the correct line, but they at least give you a clue about where the problem is located. If you get compiler errors, try to troubleshoot them yourself. Look closely at the line flagged by the compiler and at the line above it (which is often where the error actually is located). Most errors are caused by incorrect typing, misspelling something, incorrect punctuation, or incorrect case.

Oftentimes, a single error in one line will precipitate compiler errors in following lines, even though they are correct. Therefore, the best approach, if you have multiple compiler errors, is to fix the first one and recompile (Build). Often, fixing the first problem also fixes several other errors.

Some lines of code will cause the compiler to issue a Warning instead of an error. If there are only warnings and no errors, the compiler will usually be able to create an executable file. Depending on the problem, your code may still work fine, but, in general, you should fix all warnings so that you get a completely clean build.

If you get any compiler errors or warnings, try to fix them, but if you cannot figure out what to do, ask your instructor or F.A. for assistance. Remember, C++ is quite fussy about most details (punctuation, spelling, case, etc.), so edit your code carefully.

If the code compiles correctly, the next step that Visual C++ .NET performs is linking. This step simply connects your program with prewritten programs and objects that you use in your program (cin andcout in this example).

Background: Testing and Types of Errors

Just because your code compiles without errors, does not mean that it will execute correctly!

It is still possible that a program contains run-time errors.

Run-time errors fall into two basic categories:

system errors and logical errors.

System errors occur when your program runs and tries to do something that the host computer cannot or will not do, for example, divide by zero. The good news about system errors is that the system detects them, stops your program, and gives you an error message.

Part 2

Complete the following two programs:

Programming Problem 1

John wants to know the values of the area and perimeter of a rectangle. John can take measurements of the length and width of the rectangle in inches. John’s measurements are expected to be accurate to within 0.1 inch.

  1. Identify the inputs and outputs of the problem.
  2. Identify the processing needed to convert the inputs to the outputs.
  3. Design an algorithm in pseudocode to solve the problem. Make sure to include steps to get each input and to report each output.
  4. Identify two test cases, one using whole number values, and one using decimal number values. For each of the two test cases show what inputs you will use and what your expected outputs should be.
  5. Write the program to implement your algorithm. Test your program using your test cases. Did your program produce the values predicted in your test cases? Explain.

Programming Problem 2

Shirlee is working with a measurement tool that reports measurements in centimeters. Since Shirlee is unfamiliar with centimeters, she would like her centimeter measurements to be converted into yards, feet, and inches. She would also like the result to be properly rounded to the nearest inch. As an example, if the measurement is 312 centimeters, this should be converted to 3 yards, 1 foot, and 3 inches.

  1. Identify the inputs and outputs of the problem.
  2. Identify the processing needed to convert the inputs to the outputs. HINT: Convert centimeters to total number of inches first! (1 inch = 2.54 cm)
  3. Design an algorithm in pseudocode to solve the problem. Make sure to include steps to get each input and to report each output.
  4. Identify two test cases other than the example given above. For each of the two test cases show what inputs you will use and calculate what your expected outputs should be.
  5. Write the program to implement your algorithm. Test your program using your test cases. Did your program produce the values predicted in your test cases? Explain.

For each of the two programming problems, create a program using Visual C++.Net. Make sure to capture a sample of your program’s output. The best way to do this is to click on the console window you want to capture and then press the Alt and PrintScreen keys at the same time. Then paste your captured screen image into a Word document. For each of the two programs, put the screen capture followed by a copy of your source code into your Word document.

Your final programming document should contain in the following order:

  1. Answers to all of the questions listed above.
  2. Screen capture of the first program followed by source code.
  3. Screen capture of the second program followed by source code.