Algorithm Worksheet

  1. Write an algorithm to calculate the cost of a rectangular window. The total cost of a window is based on two prices; the cost of the glass plus the cost of the metal frame around the glass. The glass is 50 cents per square inch (area) and the metal frame is 75 cents per inch (perimeter). The length and width of the window will be entered by the user. The user will also enter y or n, to indicate whether or not the customer wants delivery. If the customer wants the window delivered, there is an extra charge of $50. The output of the program should be the length and width (as entered by the user) and the total cost of the window, including delivery if requested.
  2. Make up test data for the algorithm in the previous question.
  3. Let's modify the requirements of the algorithm. Smaller windows cost the standard window rates (50 cents for glass and 75 cents for metal), but for larger windows (windows more than 1000 square inches), the cost of the glass is 60 cents per square inch and the metal is 80 cents per inch. The delivery charge is $50 for larger and smaller windows. Write an algorithm for this version of the problem.
  4. Make up test data for the algorithm in the previous question.
  5. Let's modify the requirements of the algorithm again. Now windows can be purchased in standard thickness or double pane glass. If the customer wants standard thickness, the glass costs 50 cents per square inch. Double pane windows cost $1.00 per square inch with a minimum charge of $350. The metal cost for either type of window is 75 cents per inch. The user will input the length and width of the window, either d or s (for double or single pane glass), and y or n to indicate whether delivery is required. The delivery charge is $50.
  6. Make up test data for the algorithm in the previous question.
  7. Let's write one more version of the algorithm. This version will be like the previous version, except that the user can order more than one window. The program will keep reading data on windows until the user enters -1 -1 for the length and width. In addition to printing the cost of each window, the program should print the total cost of all windows at the end.
  8. Make up test data for the algorithm in the previous question.

Email Me | Office Hours | My Home Page | Department Home | MCC Home Page

© Copyright Emmi Schatz 2002