Pre-lab homework. None.
1. Write a program that converts
between Dollars, Euros and Pounds. The program reads input from the user in the
following format: Convert amount currency_1 to currency_2 and prints results in the obvious way. Here are a
couple of sample runs:
Command: Convert 3.50 Euros to DollarsResults: 4.7719 |
Command: Convert 3.50 Euros to PoundsResults: 2.3653 |
Here are the conversion rates you'll need: 1.00 Dollar is 0.73346 Euros and 1.00 Dollar is 0.49566 Pounds.
2. Extend your program from Part 1 to allow for Canadian dollars as well (1.00 Dollar US is 1.0534 Dollars Canadian). Now the user can't simply put "Dollar" in the input, it must be either "Dollar US" or "Dollar Canadian". Here are a couple of sample runs:
Command: Convert 3.50 Euros to Dollars USResults: 4.7719 |
Command: Convert 11.72 Dollars US to Dollars CanadianResults: 12.3458 |
Going Further
If you finish the above “required for turn-in” part early, you should tackle this problem:
It is often necessary to write programs that produce output
that is intended as input for other programs. You will write a program that
reads in three points from the user and prints output that the user can
cut-and-paste into Excel (or a similar program) to produce a plot showing the
triangle defined by the three user-input points along with its bounding box,
i.e. the smallest rectangle aligned with the coordinate axes that contains the
triangle. Here's a sample run of the
program:

Figure out how to
compute the “bounding box” for the three points that the user enters (to visualize
this, see the last screenshot below). Your
program will output the values of the 3 points plus a return to the first point
(the first 4 lines in the example above), then output the bounding box for
those points including a return to the first point of the bounding box (the last
5 lines in the example above).
Once your have your program producing output, you will use a
spreadsheet program to plot the points and the bounding box. Do this:
· In the labs, select Applications -> Office ->
OpenOffice.org Spreadsheet.
· In the terminal where you ran your program, highlight
the program output. Right-click and
select Copy.
· In the Spreadsheet program, do a Paste (if you have
trouble, try Edit->Paste Special).
Pick “Space” and “Tab” as delimiters if asked for what separates the
numbers.
· Highlight the two columns of numbers that you now
have. You might end up with something
like this:

· From the menu, select Insert->Chart. Then click on “XY (Scatter)” for the chart
type AND at the far right, click on the second example chart (showing points
connected by lines). It should look like
this:

· Click on Finish.
You should end up with a chart that looks like this:

Going Even Further
For a tougher challenge consider this problem:
A triangle can be classified in two ways:
A triangle can be described using these two classifications in combination. For example, Figure 1 is an acute isosceles triangle.
|
|
|
Figure 1 |
A well known property of all triangles is that the sum of any two sides will always be greater than the third. Given a set of three lengths it is possible to determine if they can form a triangle by adding two lengths together and comparing them to the third.
Given the three lengths of the sides of a triangle, a, b and c, it is also possible to calculate the area of a triangle using Heron's formula.
![]()
Where s is the semiperimeter of the triangle.
s = 1/2(a + b + c)
Also, using the lengths a, b and c, it is possible to calculate the three interior angles, A, B and C, of the triangle using the law of sines.
![]()
Where R is the radius of the circle that circumscribes the triangle. How am I supposed to calculate THAT!? Calm down, we'll tell you...
It just so happens that calculating the area of the triangle will help you. The diameter of a circumscribing circle (also known as 2R) is equal to the product of the three lengths, divided by two times the area.

Using this knowledge write a program that:
1. Display your name and alpha code.
2. Prompts the user for the three lengths of the sides of a triangle
3. Checks and states whether the given input can form a triangle
4. Calculates and displays the area of the triangle
5. Calculates and displays the measurements of all three interior angles
6. States what type of triangle is formed by the input. I.e. "This is a obtuse scalene triangle"