CS 162 Fall 2001 Assignment 2 – C++ I/O and Default Parameters 100 points
Assigned: 09/04/2001
Due: 09/11/2001 at the start of class.
Pre-Lab (Do Before Lab): Bring an empty (or nearly empty) disk.
Pairs: You may work in pairs if you want. Note, during the course of the semester, you cannot pair with any one person more than twice. If you work in a pair, turn in ONE copy that is the work of both of you, with both of your names on it. Each member of the pair will receive the same grade for that lab. In such a partnership, students must share as equally as possible the work and learning. Working together with truly shared effort and learning can be a positive experience. However, simply giving/receiving code from someone defeats the learning process. If substantial parts of a program are taken from non-partners, that is plagiarism. The copier and copyee will each receive a zero.
Main Assignment:
The Monopolysoft Corporation has requested that you provide a small piece of Windows 2001 A Computer Oddity. Your part involves (a simplification of) reporting on the amount of disk space available on removable disks. Write a program that will ask the user for the number of disks, then for each disk, ask how many bytes each file uses (obviously in the real thing, this would be pulled from the file info the system has rather than requested of a user, but we need to simplify). After the user has indicated that all files have been entered (by giving a size of –1), ask what type of disk is involved and report the disk space used and available – see sample interaction. As always, divide the program into functions. At least one must have a default parameter !! You can assume that we will not track more than 1000 files on any disk. You should validate input to ensure that the number of bytes entered is either –1 or a positive number. You must use C++ I/O!!! For my grading purposes, make your prompts go to clog, and your actual results go to cout.
Sample interaction with the user:
Obtaining info
for disk 1
Please enter
the next file size (or just -1 to end) 1800
Please enter
the next file size (or just -1 to end) 2750
Please enter
the next file size (or just -1 to end) –1
Obtaining info
for disk 2
Please enter
the next file size (or just -1 to end) 36000
Please enter
the next file size (or just -1 to end) 64000
Please enter
the next file size (or just -1 to end) 14500
Please enter
the next file size (or just -1 to end) –1
Is the disk a
floppy (1), Zip 100 (2), or Zip 250 (3) 2
Files use
114500 bytes out of 104857600 available - 104743100 remain
Obtaining info
for disk 3
Please enter
the next file size (or just -1 to end) 1000500
Please enter
the next file size (or just -1 to end) 2500050
Please enter
the next file size (or just -1 to end) –1
Is the disk a
floppy (1), Zip 100 (2), or Zip 250 (3) 3
Files use 3500550
bytes out of 262144000 available - 258643450 remain
Hand-in:
1) Listing of the program
2) Disk with your .c file and your
working .exe file. NAME YOUR PROGRAM FILE yourlastname2.c; Name your project
yourlastname2 so that the executable will be yourlastname2.exe. If you are
working in pairs, use both last names (e.g. redmondsmith2.c)
Miscellaneous:
1) Make
your program work like shown above. If you have any questions about what should
be done, please ask!!
2) MAKE SURE YOUR PROGRAM WORKS! (i.e. more than just
removing compile errors). Test it more than once - I will! Your program needs
to be able to handle any inputs
including catching invalid inputs.
3) Remember:
Indentation, meaningful variable names, symbolic constants, and meaningful comments.
Weaknesses in any of these could result in points off. You MUST include
comments that explain your program in order to get full credit. Also make sure
you put YOUR NAME(s), section, and e-mail address in comments at the beginning
of the program.
4) A
megabyte is 1048576 bytes. In my sample interaction, I have assumed capacities
of 1.4 MB for floppies, and 100 and 250 MB for zip disks.