讲解Programming解析、C/C++编程程序讲解、C/C++调试、C/C++语言设计讲解辅导、解析C/C++

- 首页 >> C/C++编程

Programming Exam 1

CMPE 126 Lab Section 02

Date: 09/25/2018 2:30-5:30pm

General guidelines

? This exam will be for 3 hours only.

? Please submit your best work by 5:30pm

? You may use external sources with citation

Academic Dishonesty

The following will be considered actions of academic dishonesty and will be reported without further

discussion.

? Copying code:

o You are NOT permitted to share code or reuse someone else's work.

? Discussing with others:

o You are NOT permitted to discuss in class or online with your classmates or anyone else

about the lab.

Expected exam etiquette

If you are found disregarding the following guidelines, you will be penalized in this exam:

? Using your cellphone – Using cellphones is strictly not allowed during exam time. Your cellphone

must be turned off (as stated in the syllabus) during your exams.

? Leaving the exam hall/lab without informing the instructor/TA.

Expected outcome from this exam

The exam will test your skills and understanding of the following concepts:

? C++ programming skills

? Problem-solving skills

? Object-oriented programming concepts - mainly encapsulation, abstraction, and polymorphism.

? Operator overloading (mainly arithmetic, logical, relational, << and >> )

? File I/O

Exam in the next page…

The problem

1. Create a class called myDate with month, date, and year fields

2. Overload the >> operator for the class to read a date in the format mm/dd/yyyy

a. E.g., 09/25/2017 should read 9 in the field month, 25 in the field date and 2017 in the

field year

3. Create a class called Student with fields name and birthday. Name should be of type string

and birthday should be of type myDate.

4. Overload >, <, <=, >= to compare two objects of type myDate

5. From a file called birthdays.txt, read a list of student birthdays in the format:

mm/dd/yyyy Alice

mm/dd/yyyy Bob

? ?

6. Print the oldest and youngest students’ name and birthdays

7. BONUS – Throw an error if the format of the date is wrong

8. BONUS 2 – Validate the date based on the calendar, e.g., 02/30/2017 should throw an error

because February has only 28 days in 2017.

Rubric

1. myDate class – 10 points

2. Operator >> overload – 25 points

3. Student class – 10 points

4. Operator >, <, >=, <= overload – 20 points

5. File read – 20 points

6. Find oldest and youngest – 15 points

7. Bonus 1 – 10 points

8. Bonus 2 – 10 points

Submission instructions

Submit the following files in a zip file:

? myDate.h

? myDate.cpp

? Student.h

? Student.cpp

? progExam1.cpp

? birthdays.txt

Name your zip file ProgrammingExam1_XXXYYYXXX.zip, where XXXYYYXXX is your SJSU ID. E.g., if your

SJSU ID is 111000111, your submission will be called ProgrammingExam1_111000111.zip.


站长地图