YALE UNIVERSITY
DEPARTMENT OF COMPUTER SCIENCE
CPSC 427: Object-Oriented Programming | Handout #2 | |
Professor M. J. Fischer | September 3, 2018 | |
Problem Set 1
Due by 11:55 pm on Wednesday, September 12, 2018.
You are to write a program called aboutme that, when run, prompts the user to enter their first name, last name, and year of birth. The program then prints out the first name, last name, and age, which we take to be the difference between the current year and the year of birth. Here’s what a sample run for me might look like:
The lines before the first prompt are printed by banner(). The lines after the age line are printed by bye().
Your own code will go into main.cpp. Needed declarations should be placed before the function main(). You will need to define the function run(), which should be placed afterthe function main.1
A variable of type string acts just like one would expect. You can store a string literal of any length into it. You can copy one string to another using the assignment operator. You can print it using the << operator and read a whitespace-delimited string into it using the >> operator. A string manages its own storage so that you do not have to worry about allocating storage. You must use string variables to store the first and last names to be read in.
Your assignment will be graded according to the scale given in Figure 1 (see below).
# | Pts. | Item |
1. | 1 | All source code is contained in the single file main.cpp. |
2. | 1 | The source code is an ascii or utf-8 text file (not a .doc file). |
3. | 1 | Code is neatly indented according to the style for this course. |
4. | 2 | main.cpp contains required authorship information. |
5. | 1 | main.cpp #includes the tools header file. |
6. | 1 | main() calls banner() and bye(). |
7. | 1 | Each function is preceded by a comment that describes briefly what it does. |
8. | 1 | Program uses C++ I/O operators << and >> with standand streams cout and cin. |
9. | 1 | Program uses good() to check for input errors and takes appropriate action in case of error. |
10. | 2 | Program correctly computes the current year using time() and localtime() functions. |
11. | 1 | A well-formed Makefile or makefile is submitted that specifies compiler options -O1 -g -Wall -std=c++17. |
12. | 1 | Running make results in an executable file aboutme and generates no errors or warnings. |
13. | 4 | A file named aboutme.out contains the output from at least two test runs of the program, one with correct input and one where a non-number was entered instead of a valid year. The inputs typed for each test run should also be included so the test output can be replicated. |
14. | 2 | All required files are submitted on Canvas as described in lecture 2. |
20 | Total points. |
|