CS133 Lab 2


Track 1

Write a program that reads the radius of a sphere and outputs the sphere's volume. The formula for a volume of a sphere is as follows:

volume = 4/3 π r3

Here is a sample run (blue type indicates user response):

Enter radius of sphere: 2.35
A sphere with a radius of 2.35 has a volume of 54.36.

Use 2 decimal places when displaying results, as indicated in the above example.

Track 2

Write a program that will read in two integer fractions and print each fraction, their sum and product. Here is a sample run:

Enter first fraction: 3/7
Enter second fraction: 4/3
The sum of 3/7 and 4/3 is 37/21.
The product of 3/7 and 4/3 is 12/21.

It is not necessary to reduce fractions to their simplest form.