Program 1: CPS 008, Spring 1995 Owen Astrachan due: January 31, 8:00 am, 20 points ******Introduction This assignment covers material through chapter 3 of the text. This covers I/O, user-defined functions, and classes. In order to do this assignment you should create a subdirectory named prog1 in your cps08 directory (see the first Unix/Emacs/C++ lab if you haven't yet created a cps08 directory). You'll need to copy a few files into this directory to facilitate the programs you'll write. Follow the steps below to do this: Change into the prog1 directory using the cd command (use mkdir to create the directory if you need to). Verify that you're in the right directory using the pwd command (print working directory). Type cp ~ola/cps08/prog1/* . which will copy all the files from the directory ~ola/cps08/prog1 into your directory. Don't forget the trailing period, or dot. If you do, you might get an error message something like "Permission denied". This should copy two files Makefile fly.cc Verify that these files have been copied by typing ls to see all the files in the current directory. *****Programs to write You'll write three programs for this assignment. Beverage Song (6 points) Write the program described in Exercise 3.5 on page 92 of the text. Feel free to embellish it. You should name the program beverage.cc. To compile from within emacs, type C-x c (to invoke the compile command) and then typing make beverage. This will invoke the g++ compiler and generate an executable file named beverage that you can run from an xterm window. If there errors you can use the C-x ` to cycle through them. Your program should prompt the user for the name of the beverage and the initial number of bottles. It should then print 3 verses of the song. Programs Printing Programs (6 points) You must write a program named nameprog.cc whose output will be similar to that described in Exercise 2.3 on pages 54-55 of the text. The output of nameprog will be a program that, if it were compiled and executed, would print a greeting for the name the user enters as shown below. ----- program run -------------------- enter a name: Bjarne #include main() { cout << "Hello Bjarne" << endl;@ } ----------------------------------------- You'll need to use the escape sequence \" to print a double quote. When you've entered the program you can compile it from within emacs by typing C-x c (to invoke the compile command) and then typing make nameprog. This will invoke the g++ compiler and create an executable file nameprog. Balloon (6 points) Write a program named fly.cc similar to the program asked for in Exercise 3.7 on page 93 of the text. However, in your program after the balloon rises to the specified altitude, the user should then be prompted for a number of meters to descend, say . The balloon should then descend to a height that is meters less than the height first ascended to. Skip step 3 in Exercise 3.7, cruise for the same number of time steps initially specified by the user. For example, if the user first enters 50 meters when prompted for the altitude, then enters 12 meters to descend, the balloon should descend to 38 meters (50-12). The number of meters to descend is relative to the initial ascent height. Submit You should create a README file as described for the first lab. In it you put the time you spent on the assignment, the names of people with whom you collaborated, and any thoughts on the assignment. To submit, use submit08 prog1 README fly.cc beverage.cc nameprog.cc The README file is worth 2 points. Extra Credit You can earn extra points by doing exercises 2.8 -- 2.11 on page 68 of the excursion section in Chapter 2. Ideally, you should type the answers and submit them electronically. However, you may also submit written hardcopy by handing the answers in at the beginning of class. To submit electronically: submit08 prog1Xtra README Where the README file contains your answers. This can earn up to 5 extra points.