Lab #2: Introduction to C++ Programming; Input / Output, and Operators - 29770

Solution Posted by
jordanblink

jordanblink

Rating : (19)A+
Solution Detail
Price: $30.00
Request Description

Florida Institute of Technology

Department of Electrical and Computer Engineering

 

ECE 2551 – Software/Hardware Design

 

Fall 2013

 

 

 

 

 

 

Lab #2: Introduction to C++ Programming; Input / Output, and Operators

Reference: Chapter 2

Overview:

In this lab you will learn many important basic features of C++, including displaying data on the screen, inputting data from the keyboard, and declaring variables of fundamental types.  In particular, you will get hands-on experience with using the output stream object cout and the input stream object cin to build simple interactive programs.  You will also work with variables to store and retrieve data to/from memory and use arithmetic operators to perform calculations.  You will also experience the order in which C++ applies operators (i.e., the rules of operator precedence), as well as the associativity of the operators, and gain experience using C++’s if statement to allow programs to make decisions.  Finally, you will be introduced to the equality and relational operators, which are used to form conditions in if statements.

Lab Objectives:

·         To write simple computer programs in C++.

·         To write simple input and output statements.

·         To use fundamental types.

·         Basic computer memory concepts.

·         To use arithmetic operators.

·         To learn precedence of arithmetic operators.

·         To write simple decision-making statements.

Lab 1a: Order of Evaluation (15 minutes)

Write a program that computes the following values of x and displays the output to the screen.

·         x1 = 7 + 3  6 / 2 – 1

·         x2 = 2 % 2 + 2  2 – 2 / 2

·         x3 = ( 3  9  ( 3 +  (9  3 / ( 3 ) ) ) ) 

 

When you complete the program and the output is displayed to the screen, call the lab instructor and explain how the program computed the output of each of the x1, x2, and x3 variables to obtain full credit.

Lab 1b: Arithmetic, Decision-Making (30 minutes)

Write a program that inputs three integers from the keyboard and prints the sum, average, product, smallest, and largest of these numbers.  The screen dialog should appear as follows:

 

Input three different integers: 13 27 14

Sum is 54

Average is 18

Product is 4914

Smallest is 13

Largest is 27

 

To obtain full credit, call the lab instructor and show him/her your code; compile, and execute the code to display the correct output on the screen.

Lab 1c: Simple Input / Output Statements (30 minutes)

(Body Mass Index Calculator), we introduce the body mass index (BMI) calculator in Exercise 1.9. The formulas for calculating BMI are

 

Or

 

Create a BMI calculator application that reads the user’s weight in pounds and height in inches (or, if you prefer, the user’s weight in kilograms and height in meters), then calculates and displays the user’s body mass index. Also, the application should display the following information from the department of health and Human Services/National Institute of Health so the user can evaluate his/her BMI:

 

The screen dialog should appear as follows:

BMI Values

Underweight: less than 18.5

Normal:      between 18.5 and 24.9

Overweight:  between 25 and 29.9

Obese:       30 or greater

 

Your BMI is <<output>>

 

To obtain full credit, call the lab instructor and show him/her your code; compile, and execute the code to display the correct output on the screen.

 

 

Solution Description

I have around 8 yrs of professional software development experience. I can provide t

Attachments
lab2.zip
lab2.zip