inheretance-need help guys before tomorrow

The code snippet below is of an Account class.

class Account
{

float balance;
float deposit(float depAmt)
{
balance = balance + depAmt;
return balance;
}
float withdraw(float withAmt)
{
balance = balance - withAmt;
return balance;
}
};



a) You are to write a complete program which satisfies all of the the following:
-Include the appropriate access specifiers for the member variables and member functions.
-Include an additional member function to the Account class called setBalance(), which sets the balance value to a value passed to the function.
-Create a new class called SavingsAccount which is derived from the Account class.
-Override the withdraw() function to satisfy the condition that the minimum balance of a savings account must be P100.00 (ignore the currency symbols).  -Create an object of the Savings Account.

-Set the balance of the SavingsAccount object to P250.00, deposit P182.26 then withdraw P100.00. 
Withdraw an additional P310.00 from the balance left above. 
Display the balance and /or any relevant message after each withdrawal in the two cases above.
First, use code markup.

You put
[code]
before code, and
[/code]
after code, so it becomes readable.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
class Account
{

  float balance;
  float deposit(float depAmt)
  {
    balance = balance + depAmt;
    return balance;
  }
  float withdraw(float withAmt)
  {
    balance = balance - withAmt;
    return balance;
  }
}; 


Secondly, start at the top of the instruction and work down. Here's the first thing you need to do:
Include the appropriate access specifiers for the member variables and member functions.


Have you done that yet?
Last edited on
Topic archived. No new replies allowed.