You are on page 1of 1

Week 3 Lab Exercises

Question 1

Write a C++ program for computing volume of a cylinder. Use the formula:

Where r and h are the radius and height of the cylinder respectively

Question 2

Write a C++ program that prompts the user to input the elapsed time for an event in hours, minutes
and seconds. The program then outputs the elapsed time in seconds.

Question 3

Cindy uses the services of a firm to buy and sell stocks. The firm charges 1.5% service charges on the
total amount for each transaction, buy or sell. When Cindy sells stocks, she would like to know if she
gained or lost on a particular investment. Write a C++ program that allows Cindy to input the
number of shares sold, the purchase price of each share, and the selling price for each. The program
outputs the amount invested, the total charges, amount gained or lost, and received after selling the
stock.

Question 4

Write a C++ Program that accepts as input the mass (in grams) and density (in grams per cubic
centimeters), and output the volume of the object using the formula: density=mass/volume.

You might also like