Question

PYTHON PROGRAMMING LANGUAGEDesign a class named Savings Account that contains: A private int data field named id for the savings account. A private floa

0 0
Add a comment Improve this question Transcribed image text
Answer #1

CODE IN PYTHON:

class Savings_Account: def __init__(self, id = 0, balance = 0, interestRate = 0): self.__id = id self.__balance = balance self.__annualInterestRate = interestRate def getBalance(self): return self.__balance def getId(self): return self.__id def getAnnualInterestRate(self): return self.__annualInterestRate def setBalance(self, balance): self.__balance = balance def setId(self, id): self.__id = id def setAnnualInterestRate(self, interestRate): self.__annualInterestRate = interestRate def getMonthlyInterestRate(self): return self.__annualInterestRate / 12 def getMonthlyInterest(self): return self.__balance * self.getMonthlyInterestRate() / 100 def withdraw(self, amount): if self.__balance >= amount: self.__balance -= amount else: print("Insufficient funds...") def deposit(self, amount): self.__balance += amount account = Savings_Account(1234, 25000, 3.5) account.withdraw(2500) account.deposit(3000) print("ID : ", account.getId()) print("Balance : ", account.getBalance()) print("Monthly Interest rate : ", account.getMonthlyInterestRate()) print("Monthly Interest : ", account.getMonthlyInterest()) INDENTATION:

class Savings Account: def __init__(self, id = 0, balance = 0, interestRate = 0): self._id = id self. __balance = balance selaccount = Savings Account(1234, 25000, 3.5) account withdraw(2500) account.deposit(3000) print(ID : , account.getId()) prin

OUTPUT:

Savings Account C:\Users\madhu\venv\Python3.8\Scripts\python.exe D:/PythonWorld/HelloWorld/Savings_Account.py ID : 1234 Balan

Add a comment
Know the answer?
Add Answer to:
PYTHON PROGRAMMING LANGUAGE Design a class named Savings Account that contains: A private int data field...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 9.7 (The Account class) Design a class named Account that contains: • A private int data...

    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. •...

  • (The Account class) Design a class named Account that contains: A private int data field named...

    (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...

  • Design a class named BankAccount that contains: 1. A private int data field named accountId for...

    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...

  • New to python if you can add screenshort also, i am using python 3 7.3 (The...

    New to python if you can add screenshort also, i am using python 3 7.3 (The Account class) Design a class named Account that contains A private int data field named id for the account. A private float data field named annualInterestRate that stores the current A constructor that creates an account with the specified id (default 0), initial The accessor and mutator methods for id, balance, and annualInterestRate A private float data field named balance for the account. interest...

  • Design a class that contains: we have to make 3 files header file , one .cpp...

    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 Account that contains: A private int datafield named id(default 0) A private...

    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$ .

  • Consider the following Account class and main function: class Account: acct_num=1000 #Constructor for Account class (default...

    Consider the following Account class and main function: class Account: acct_num=1000 #Constructor for Account class (default values for balance #and annual interest rate are 100 and e, respectively). #INITIALIZER METHOD HEADER GOES HERE #MISSING CODE def getId(self): return self._id def getBalance(self): #MISSING CODE def getAnnualInterestRate(self): return self.___annualInterestRate def setBalance(self, balance): self. balance - balance def setAnnualInterestRate(self,rate): #MISSING CODE def getMonthlyInterestRate(self): return self. annualInterestRate/12 def getMonthlyInterest (self): #MISSING CODE def withdraw(self, amount): #MISSING CODE det getAnnualInterestRate(self): return self. annualInterestRate def setBalance(self,...

  • Design a class named BankAccount containing the following data field and methods. • One double data...

    Design a class named BankAccount containing the following data field and methods. • One double data field named balance with default values 0.0 to denote the balance of the account. • A no-arg constructor that creates a default bank account. • A constructor that creates a bank account with the specified balance.  throw an IllegalArgumentException when constructing an account with a negative balance • The accessor method for the data field. • A method named deposit(double amount) that deposits...

  • in java Account that contains: balance: double data field date: Date data field. Use Date class...

    in java Account that contains: balance: double data field date: Date data field. Use Date class from the java.util package accountNumber: long data field. You should generate this value randomly. The account number should be 9 digits long. You can you random method from java Math class. annuallnterestRate: double data field. customer: Customer data field. This is the other class that you will have to design. See description below. The accessor and mutator methods for balance, annuallnterestRate, date, and customer....

  • THE FOLLOWING PROGRAM IS NEEDED IN JAVA LANGUAGE Design a class torepresent account, include the following...

    THE FOLLOWING PROGRAM IS NEEDED IN JAVA LANGUAGE Design a class torepresent account, include the following members: -Data Members a)Name of depositor-Stringb)Account Number –intc)Type of account –Boolean d)Balance amount -doublee)AnnualInterestrate -double Methods: -(a)To assign initial values (use constructor)(b)To deposit an amount.(c)TO withdraw amount with the restriction the minimum balance is 50 rs. Ifyouwithdraw amount reduced the balance below 50 then print the error message.(d)Display the name and balance of the account.(e)Get_Monthly_intrestRate() -Return the monthly interestrate whichis nothing but Annualintrestrate/12. Annualinterestrate...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT