This action might not be possible to undo. Are you sure you want to continue?

Welcome to Scribd! Start your free trial and access books, documents and more.Find out more

Problem Description: Students at a local middle school that you have been tutoring are having some difficulty with basic area formulas that they learn in math class. You decided to write a simple computer program that will help them with a few of these concepts. Program Directions: Write a C++ program that uses the information found in the formula section to calculate the area of a rectangle, parallelogram, or trapezoid. The program must do the following: • Ask the user to input his/her first name • Ask the user to choose the shape of which to calculate the area o Program must take both upper and lower characters • Ask the user to input the lengths and/or the height of shape • Calculate the area of the shape • Display to the screen the area of the shape Formulas

rectangle = ab

parallelogram = bh

trapezoid = h/2 (b1 + b2)

Program Output The program should display the following: • The name of the user • The area of the shape

Program Calculations Failure to include the formulas in the program will result in a deduction of points on the assignment. Program Header Information • Name • Program number • Collaboration statement • The answers to the following question: o What is the purpose of the program? o What is the input? (Is there any?) o What is the output? Failure to include this information as comments at the beginning of your program will result in a deduction of point. Sample Run Below is a sample run. DO NOT include additional input or output streams in your program.

**This program received 100/100 points from Dr. Cynthia Lester.
**

/* Adonis Brown Program #1 I worked on the assignment by myself and received no additional assistance. Questions: 1. The purpose of this program is to find the area of a certain shape (using user entered integers), then print it to the screen. 2. The inputs are the sides (and heights of certain shapes), as well as the user's name. 3. The outputs are the area of the figure whose sides (and heights)were input, as well as the user's name when asking for input.*/ #include <string> #include <iostream.h> #include <stdlib.h> int main() { char shape; string name; double rs1 = 0, rs2 = 0, pb = 0, ph = 0, tb1 = 0, tb2 = 0, th = 0; cout <<"Please enter your name:"<<endl; cin>>name; cout<<endl<<name<<", please choose one of the selections below:"<<endl <<"------------------"<<endl; cout<<"R = Rectangle |"<<endl<<"P = Parallellogram|"<<endl<<"T = Trapezoid |"<<endl; cout<<"------------------"<<endl; cin>>shape; if (shape == 'R'||shape == 'r') {

cout<<"Please enter the lengths of the two sides of the rectangle: "; cin>>rs1>>rs2; if (rs1 <= 0 || rs2 <= 0) cout<<"The lengths can not be negative."<<endl; else cout<<"The area of your rectangle is "<<(rs1*rs2)<<"."<<endl; } else if (shape == 'P'||shape == 'p') { cout<<"Please enter the length of the base of your parallellogram: "; cin>>pb; cout<<"Please enter the height of your parallellogram: "; cin>>ph; if (pb <= 0 || ph <= 0) cout<<"The lengths can not be negative."<<endl; else cout<<"The area of your parallellogram is "<<(pb*ph)<<"."<<endl; } else if (shape == 'T'||shape == 't') { cout<<"Please enter the first base of your trapezoid: "; cin>>tb1; cout<<"And now the second base: "; cin>>tb2; cout<<"Finally, enter the height of your trapezoid: "; cin>>th; if (tb1 <= 0 || tb2 <= 0 || th <=0) cout<<"The lengths can not be negative."<<endl; else cout<<"The area of your trapezoid is "<<(th/2*(tb1 + tb2))<<"."<<endl; } else cout<<shape<<" is not a valid entry."<<endl; system("PAUSE"); return 0; }

1st programming assignement Summer Semester 2007

1st programming assignement Summer Semester 2007

- LP - trapezoid.docx
- Geometric Transformation
- Visio 2003 Professional Basic Tutorial
- Roundness
- Lets Get in Shape
- Aj 2418721874
- AB WS 041 Reimann Sum Approximation 1
- homeworkmateting3-120919184022-phpapp02
- GHT-notes
- Visio Tutorial ER Diagram
- Rectangle detection using Hough Transform
- Projection of Planes
- Mathed PDF Presentit Fractals
- Annotating Search Results From Web Databases
- E.G. Coffman Jr, Peter J. Downey and Peter Winkler- Packing Rectangles in a Strip
- Junior 05 Eng
- 16410papaer for Karan
- Areas.between.curves.0
- 126 Studying Fine-Art Compositions by Means of Dynamic Geometry Constructions 2013(1)
- Alcatel Lucent
- MINGGU 1.doc
- Final Observation Translation 32013
- Andrew Schoenfeld Art Criticism
- Solutions
- integassum
- Scribd Cpu
- early-childhood-art-kellogg-and-viktor-lowenfeld.ppt
- Creating a 3D Screw
- Statics AA 53
- Using Where Conditions to Relate Header and Item Tables in Adobe Forms

Are you sure?

This action might not be possible to undo. Are you sure you want to continue?

We've moved you to where you read on your other device.

Get the full title to continue

Get the full title to continue reading from where you left off, or restart the preview.

scribd