Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question 1: Create a Person class that includes fields for last name, first name, and zip code. Include a default constructor that initializes last name,

Question 1:

Create a Person class that includes fields for last name, first name, and zip code. Include a default constructor that initializes last name, first name, and zip code to Unknown if no arguments are supplied. Another constructor should be included where you supply your own values. Also include a display function.

Create another class named SavingAccount. Provide fields for the customer (use the Person class), accountNumber and balance. Provide two constructors. One requires a customer and sets each numeric field to 0; the other requires a customer and an account number and sets the accounts opening balance to $100. Include a function that displays an accounts data fields.

Include the following methods as member of the SavingAccount class:

Deposit and Withdraw, each method has an integer argument and should update the balance member.

Instantiates two SavingAccount objects using both constructor and test all the methods. Use the separated files approach when creating the project (header, implementation and drive files). Also, use Member Initialization List (MIL) whenever its possible. Make sure to include destructors for both classes.

Question 2:

Write a C++ program to accept the student detail such as name and 3 different marks by get_data () method and display the name and average of marks using display () method. Define a class for calculating the average of marks using the method mark_avg (). The get_data (), display () and mark_avg () must be friend methods.

Include a constructor with four arguments to set the members. Test the methods.

Question 3:

Write a C++ program to print the following by reading number of rows to be printed from the user. Make sure that the user will enter an odd number and if didnt, the program should print an error message and exit.

* * * * * * *

* * * * * *

* * * * *

* * * *

* * *

* *

*

Question 4:

Create a new C++ header file called Circle.h. Enter the following description of a circle class:

#ifndef CIRCLE_H

#define CIRCLE_H

#incliude

using namespace std;

class Circle {

friend bool operator == (Circle C1, Circle C2);

//return true if area of C1 equals area of C2, otherwise it returns false

friend bool inside(Circle C1, Circle C2);

// return true if C1 is inside C2 or C2 is inside C1, otherwise it returns false

public:

Circle ();

Circle (float R, int X, int Y);

void SetRadius (float R);

float GetRadius () const;

Circle& operator = (Circle C); // assign C members to the object members

void WriteArea (ostream & outs) const;

private:

float radius;

int x,y;

};

#endif

Create a new C++ implementation file called Circle.cpp. This file should contain the implementations of the functions in the Circle class. Also, create an application program to test your Circle class.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Information Modeling And Relational Databases

Authors: Terry Halpin, Tony Morgan

2nd Edition

0123735688, 978-0123735683

More Books

Students also viewed these Databases questions