P. 1
Assignment 1

Assignment 1

|Views: 53|Likes:
Published by Selmaan Qureshi

More info:

Published by: Selmaan Qureshi on Apr 09, 2012
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as DOC, PDF, TXT or read online from Scribd
See more
See less

01/29/2013

pdf

text

original

Faculty of Engineering GNG 1106: Fundamentals of Engineering Computation Assignment 1: Geometric Shapes in Cartesian Coordinates

Report Due Date: Sunday Feb 5 at midnight

Problem
Write a program that would calculate the perimeter and area of the following geometric shapes in Cartesian coordinates: • • • Rectangle Circle Triangle

Requirements
The program should start by printing a menu to the user as follows: Welcome to Cartesian geometry! Please choose a shape by entering its number: Rectangle => enter 1 Circle => enter 2 Triangle => enter 3 EXIT Program => enter 4 If the user enters a number outside of 1, 2, 3, or 4, the program should say Invalid choice and exit. After the user has chosen the shape, the program should ask for the Cartesian coordinates relevant to that shape; i.e.: • for rectangle: program should ask for the (x,y) coordinates of the four corners; • for circle: program should ask for the (x,y) coordinates of the center and a point (any point) on the circle; • for triangle: program should ask for the (x,y) coordinates of the three corners. It is up to you to decide in what order and how the coordinates should be entered by the user, as long as your program makes this clear to the user when it asks for the coordinates. ASSUMPTION: this is a huge assumption, but we are making it to make life easier for us. We
Page 1 Pages of 2

the program should print the perimeter and area of the shape.2) (3. then it is wrong because they do not form a rectangle (see picture below)! But in this lab we do not check for such things. In the real world. Page 2 Pages of 2 .2). if the user chooses Rectangle and enters the following coordinates (0. and exit. After receiving the coordinates for the chosen shape. you must check for such things! So in this program.0) (0. For example.0) (2.are going to assume that the user will only enter correct information. in your engineering problems. so we are not going to check for mistakes made by the user. we are going to test only correct coordinates.

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->