Ecet1444 – Lab1

Due in 3 weeks

Objectives

The objective of lab exercises is for student to become familiar with the constructs of the C/C++ constructs related to:

  • The structure of a C program
  • Input/Output operation in C++
  • Control structures
  • Repetitive tasks (Loops – while, do while, and for (init, condition, loop control counters).
  • Introduction to member functions

Pre-lab activities:

1-read chapter 2 and 4

2-Answer odd numbered questions in chapter 2 and 4

3-Manually write the programs related to the lab exercises by hand and review it to get a sense of assurance that your program works.

Lab activities.

  • Exercise 1:
  • Write a program that prompts the user to enter a value that represents a temperature reading in centigrade. The program will convert the input to the equivalent Fahrenheit and display the conversion on the monitor.
  • C/C++ constructs uses: cin, cout, variable declaration, assignment operator, multiplication operator, division operator,

For example if the user enter the temperature reading 0 the program should display the equivalent Fahrenheit temperature = 32 degrees.

  • Exercise 2:
  • Modify the program you wrote in exercise 2 to allow the user the option to convert from Fahrenheit to centigrade or from centigrade to Fahrenheit. The first step is that the program prompts the user to enter the type of conversion he/she wants to make. For example enter 1 if you want to convert from Fahrenheit to centigrade, enter 2 to convert from centigrade to Fahrenheit. The program then performs the selected conversion and display the output to the monitor. C/C++ constructs used in this exercise are all of what is in exercise 1. in addition IF, IF-ELSE, or the switch statement.
  • Exercise 3:
  • Modify the program you wrote in 2 or write a new program. The program in this exercise deals with generating a conversion table for a range of temperatures. The in pit can be either in Fahrenheit or centigrade. The user will also enter a staring temperature, and ending temperature and an increment that will be used to advance through the table. For example if the user enter the following information after the program prompted him/her for input:

Conversion type: 2 (Celsius  Fahrenheit)

Starting temperature: 0

Ending temperature: 100

Increment : 2

The output will be in the form of:

Celsius temperatureFahrenheit Temperature

032

2

………………………………………

………………………………………

100 212

Lab Report

The report should follow the following format

  1. Introduction

The introduction describe the over all objective of the lab. It describes what you are expected to learn from this lab. It should mention the software package you used to solve the exercises in the lab and so on (graded)

  1. Pre-lab activities (not graded but required)
  2. Flow chart for your solution of exercise 1, 2, and 3 with some description of how you solved each exercise.
  3. The code for each exercise with lots of comments explaining the different parts and instructions of your program. There will be an oral defense in the lab to get the part graded. (the instructor will ask you questions in the lab related to how you did certain things, how the relate to each other and how did you arrive to having certain parts of the program to work). Make sure you have clean code with 0 compilation error. I will help you in the lab with the logic of your program.

Good luck on your first assignment in the C++ course. I look forward to work with each and every one of you to have an enjoyable learning experience. Remember I am her to facilitate learning.

Professor Michael khader