CS 1620 Assignment #3 Fall 2000

How to handin.
Points : 50
Due: Mon Oct 16, 2000 @ midnight
Note: Late assignments will be accepted only with the instructor's pre-approval.

Marks will be awarded for comments, style, readability, compiling and working correctly.
  1. [10] Problem 5 Page 164 in the textbook

  2. [10] A litre is 0.264179 gallons. A mile is 1.6 kilometers. Write a program that will read in the number of litres of gasoline consumed by the user's car and the number of kilometers traversed by the car, and will output:
    1. the number of kilometers per litre the car delivered
    2. the number of miles per litre the car delivered
    3. the number of kilometers per gallon the car delivered
    4. the number of miles per gallon the car delivered
    Define a function for each case.

  3. [15] The price of stocks is normally given to the nearest eighth of a dollar; for example, 29¾ or 89½. Write a program that computes the total value of the user's holding of a particular stock. The program asks for the number of shares of the stock owned, the whole dollar portion of the price and the fraction portion. The fraction portion is to be input as two int values, one for the numerator and one for the denominator. The program then outputs the value of the user's holding. Your program will include a function definition that has three int arguments consisting of the whole dollar portion of the price and the two integers that make up the fraction part. The function returns the price of one share of stock as a single number of type double.

  4. [15] Write a program to gauge the rate of inflation for the past year. The program asks for the price of an item (such as a hot dog or a one carat diamond) both one year ago and today. It estimates the inflation rate as the difference in price divided by the year ago price. Define a function to compute the rate inflation. The inflation rate should be a value of type double giving the rate as a percent, for example 5.3 for 5.3%.

    Enhance your program by having it also print out the estimated price of the item in one and in two years from the time of the calculation. The increase in cost over one year is estimated as the inflation rate times the price at the start of the year. Define a second function to determine the estimated cost of an item in one year, given the current price of the item and the inflation rate as arguments.


Assignment List | Prev | Next | Computer Science 1620
Department of Mathematics & Computer Science
University of Lethbridge Home Page