Write a program that calculates the slope and length of


ASSIGNMENT - DESCRIPTION

This lab is based on the material studied in the first three weeks of the course, including exercises done in the class.

This assignment is to be done individually; you are not allowed to work on this assignment with anyone.

You are to write a program that calculates the slope and length of sides and the perimeter of a rectangle given four of its vertices as ordered pairs (x,y).

A vertex is a point which consists of an x-value and a y-value, and you have four points as the vertices of a rectangle, so you'll need to prompt the user to enter the x-value and y-value for the four vertices of the triangle. You'll need to store these input values inside variables that are declared with appropriate names and data types. Your prompts to the user should be clear, concise, and use proper spelling/grammar.

An example of user interaction should be similar to this (note that values in green are the keystrokes typed by the user):

Recording Vertex A: Enter X-Value: 5.5
Enter Y-Value: 1.0 Recording Vertex B: Enter X-Value: 10.5
Enter Y-Value: 1.0 Recording Vertex C: Enter X-Value: 5.5
Enter Y-Value: 7.5 Recording Vertex D: Enter X-Value: 10.0
Enter Y-Value: 7.5

Your program should display the vertices of the rectangle before it calculates its area. See the proper formatting below.

Sample program output (sample values used here, you may use different values if you wish; you can use these values shown below to test your program).

Vertex A: (5.5, 1.0)
Vertex B: (10.5, 1.0)
Vertex C: (10.5, 7.5)
Vertex D: (5.5, 7.5)

The length of rectangle sides AB, BC, CD, and DA are: 5, 6.5, 5 and 6.5 units and perimeter and area of the rectangle are:

23.00, 32.50 units respectively.

Your user prompts and output must appear exactly as shown above. Vertices must be formatted with one decimal digit and other calculations should be formatted with exactly two digits after the decimal.

Your program must use variables of the appropriate type and with self-documenting names.

You must include appropriate documentation in your code.

Useful Formula

The length of side AB with points A(x1, y1) and B(x2, y2) as its vertices is given by:

AB = √(x2 - x1)2 + (y2-y1)2

Request for Solution File

Ask an Expert for Answer!!
Computer Engineering: Write a program that calculates the slope and length of
Reference No:- TGS02193910

Expected delivery within 24 Hours