Design a class named Account that contains:
A private int datafield named id(default 0)
A private double datafield named balance(default 0)
A no-arg constructor that creates default account
A constructor that creates an account with specified id & balance
The getter and setter methods for id and balance.
Create an object of account class using default constructor and update the balance to 2000$ .
Hello
If there is any doubt feel free to Comment, A Like
would be highly appreciated.
Here is the Program in which i have created All the attributes and function required apart from that i have created one display member function to check the difference which i have commented for better understanding.
This is the program
As per the Question they have just asked to update the balance not
to check and display so no output although i made one display
function if required.
In case you need to copy Code,
So here it is:
#include <iostream>
class
Account
{
//Private
Attributes
int id;
double
balance;
public:
//No Argument
Contructor
Account()
{
id=0;
balance=0.0;
}
//Argument
Constructor
Account(int aid, double
bal)
{
id=aid;
balance=bal;
}
//Getter and Setter
method
int get_id()
{
return id;
}
double
get_balance()
{
return
balance;
}
void set_id(int
aid)
{
id=aid;
}
void set_balance(double
bal)
{
balance=bal;
}
/*
************To display Id
and Balance if required********************
void display()
{
std::cout <<
id<<" has "<<balance << std::endl;
}*/
};
int main()
{
//Creating Account object
with default Constructor
Account
ac=Account();
/*
//Before
update
ac.display();
*/
//Updating
Balance
ac.set_balance(2000);
/*
//After update
ac.display();
*/
return 0;
}
Thanks:)
Design a class named Account that contains: A private int datafield named id(default 0) A private...
(The Account class) Design a class named Account that contains: A private int data field named id for the account (default 0). A private double data field named balance for the account (default 0). A private double data field named annualInterestRate that stores the current interest rate (default 0). Assume all accounts have the same interest rate. A private Date data field named dateCreated that stores the date when the account was created. A no-arg constructor that creates a default...
9.7 (The Account class) Design a class named Account that contains: • A private int data field named id for the account (default o). • A private double data field named balance for the account (default o). • A private double data field named annualInterestRate that stores the current interest rate (default o). Assume that all accounts have the same interest rate. • A private Date data field named dateCreated that stores the date when the account was created. •...
Design a class named BankAccount that contains: 1. A private int data field named accountId for the account. 2. A private double data field named accountBalance for the account (default 0). 3. A private double data field named annualInterestRate that stores the current interest rate (default 0). Assume all accounts have the same interest rate. 4. A private Date data field named dateCreated that stores the date when the account was created. 5. A private int data field named numberOfDeposits...
PYTHON PROGRAMMING LANGUAGE Design a class named Savings Account that contains: A private int data field named id for the savings account. A private float data field named balance for the savings account. A private float data field named annuallnterestRate that stores the current interest rate. A_init_ that creates an account with the specified id (default 0), initial balance (default 100), and annual interest rate (default 0). . The accessor and mutator methods for id, balance, and annuallnterestRate. A method...
Design a class that contains: we have to make 3 files header file , one .cpp file for function and one more main cpp file 9.3 (The Account class) Design a class named Account that contains: An int data field named id for the account. A double data field named balance for the account. A double data field named annualInterestRate that stores the current interest rate. A no-arg constructor that creates a default account with id 0, balance 0, and...
. Design a class named MyInteger. The class contains: An int data field named value that stores the int value represented by this object. A constructor that creates a MyInteger object for the specified int value. A getter method that returns the int value. The methods isEven(), is Odd(), and isPrime() that return true if the value in this object is even, odd, or prime, respectively. The static methods isEven(int), isOdd(int), and isPrime(int) that return true if the specified value...
Part I: (The Myate class) Design a class named MyDate. The class contains: • The data fields year, month, and day that represent a date. Month is 0-based, i.e., 0 is for January. • A no-arg constructor that creates a MyDate object for the current date. • A constructor that constructs a MyDate object with a specified elapsed time since midnight, January 1, 1970, in milliseconds. • A constructor hat constructs a MyDate object with the specified year, month, and...
Design a class named StopWatch. The class contains: - Private data fields startTime and endTime with getter methods. - A no-arg constructor that initializes startTime with the current time. - A method named start() that resets the startTime to the cur- rent time. - A method named stop() that sets the endTime to the current time. A method named getElapsedTime() that returns the elapsed time for the stopwatch in milliseconds. - The System.currentTimeMillis() method returns the current number of milliseconds....
In Python - Design a class named Time. The class contains: -Data fields hour, minute, and second that represent a time. -A no-arg constructor that creates a Time object for the current time.(the values of the data fields will respresent the current time.) -A constructor that constructs a Time object with a specified hour, minute, and second, respectively. -A constructor that constructs a Time object with a specified elapsed time since midnight, Jan 1, 1970, in milliseconds. (The values of...
QUESTION 5 (15 Marks) Inheritance and Polymorphism Design a Ship class that has the following members: • A private String data field named name for the name of the ship. • A private String data field named yearBuilt for the year that the ship was built. • A constructor that creates a ship with the specified name and the specified year that the ship was built. • Appropriate getter and setter methods. A toString method that overrides the toString method...