CptS 122 – Data Structures                                                                         

 

Lab 7: The Wonderful World of C++, Classes, and Objects

 

Assigned: Week of October 8, 2012

Due: At the end of the lab session

 

I. Learner Objectives:

 

At the conclusion of this programming assignment, participants should be able to:

 

II. Prerequisites:

 

Before starting this programming assignment, participants should be able to:

 

III. Overview & Requirements:

 

This lab, along with your TA, will help you navigate through designing, implementing, and testing classes in C++.

 

Labs are held in a “closed” environment such that you may ask your TA questions. Please use your TAs knowledge to your advantage. You are required to move at the pace set forth by your TA. Please help other students in need when you are finished with a task. You may work in pairs if you wish. However, I encourage you to compose your own solution to each problem. Have a great time! Labs are a vital part to your education in CptS 122 so work diligently.

Tasks:

  1. Write a class called CreditReport. This class represents a real-world credit report. It should contain a credit score (ranges 330 – 830), a debt profile (total real estate and credit card debt), account types (number of real estate, credit cards, and retail cards), length of history (oldest account age and average account age), and number of hard inquiries (number of times your credit report has been accessed) as attributes. Operations that may be applied to your CreditReport include: printReport and updateReport (you may refine updateReport for use with individual class attributes). Be sure to include all necessary getters and setters, constructors, and destructors. At this point, do not define a copy constructor or overloaded operators. Use the automatic copy constructor which is generated for each class. Write an application which instantiates three credit reports. These include Experian, TransUnion, and Equifax. Your application should decrease credit scores as the credit limit on cards is approached and increase scores as the credit is paid off. Also the older the credit accounts, the higher the credit score. Also, use the other attributes of the CreditReport as you see fit.

 

  1. Complete programming project Complex numbers from your Deitel and Deitel C How to Program book (Exercise 17.5).

     Create a class called Complex for performing arithmetic with complex numbers. Write a program to test your class. Complex numbers have the form

            realPart + imaginaryPart * i

     where i is

                sqrt (-1)

     use double variables to represent the private data of the class. Provide a constructor that enables an object of this class to be initialized when it is declared. The constructor should contain default values in case no initializers are provided. Provide public member functions that perform the following tasks:

            a) Adding two Complex numbers: The real parts are added together and the imaginary parts are add together.

            b) Subtracting two Complex numbers: The real part of the right operand is subtracted from the real part of the left operand, and the imaginary part of the operand.

            c) Printing Complex numbers in the form (a, b), where a is the real part and b is the imaginary part.

     BONUS: Explore how to overload the + and – operators. This is not a requirement for this problem!

IV. Submitting Labs:

 

V. Grading Guidelines: