Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Lab Assignment #3 Simple If / Else And Case For all programming assignments, the following type of comment block should be at the top of

Lab Assignment #3 Simple If / Else And Case

  1. For all programming assignments, the following type of comment block should be at the top of the program:

// Your Full Name

// CSC133-xx (substitute your section number for the xx)

// Labxxxxx.cpp [the actual program name]

// This program will . [Main purpose of the program]

  1. All output for all programs should display the following on the first several lines of printed output:

(1) -------------------------------------------------------------------------------------------------------------------------

(2) Your Full Name CSC133-xx Labxxxx.cpp Date Printed

(3) -------------------------------------------------------------------------------------------------------------------------

(4) (A blank line)

  1. Assignments:

1. Your brother/sister is currently taking a geometry class. They would like you to create a program that they can use to verify calculations. Specifically, they want the program to calculate the area of a square, rectangle, parallelogram, circle, and triangle. Write a program that enters a numeric code that represents the type of area calculation to perform. A code of 1 represents a square, 2 is a rectangle, 3 is a parallelogram, 4 is a circle, and 5 is a triangle. The program will also need to enter the dimensions of the shape. The program should calculate the area of the shape. It should also display the name of the shape (Square, Rectangle, and so on) and the area. If an invalid code is entered, display an error message and the bad code entered. A nested if / else structure should be used to handle the 6 possible entry types.

a. Execute the program four times, using the following data:

(1) A square side measurement of 4,

(2) A rectangle length of 5 and width of 3,

(3) A parallelogram base of 3 and height of 4,

(4) An invalid shape with a number other than 1-5.

b. Save the program as lab3ifsh.cpp.

c. For this program, hand in:

  1. A copy of the source code for each of the programs.
  2. A copy of the screen print for the output for each of the program runs
  3. (Remember you will run this program 4 times and produce output for each run.)

2. Rewrite problem #1 above using a Switch (case) structure in place of the nested if / else structure.

a. Execute the program three times, using the following data:

(1) A circle radius of 2,

(2) A triangle base of 4 and height of 3,

(3) An invalid shape with a number other than 1-5.

b. Save the program as lab3swsh.cpp.

c. For this program, hand in:

  1. A copy of the source code for each of the programs.
  2. A copy of the screen print for the output for each of the program runs
  3. (Remember you will run this program 3 times and produce output for each run.)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Database Relational Model A Retrospective Review And Analysis

Authors: C. J. Date

1st Edition

0201612941, 978-0201612943

More Books

Students also viewed these Databases questions

Question

Discuss the major tools in the designers toolkit.

Answered: 1 week ago

Question

What is Change Control and how does it operate?

Answered: 1 week ago

Question

How do Data Requirements relate to Functional Requirements?

Answered: 1 week ago