Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
11th Edition
ISBN: 9780134743356
Author: Paul J. Deitel, Harvey Deitel
Publisher: PEARSON
Question
Book Icon
Chapter 3, Problem 7.1E
Program Plan Intro

Modified Account Class

Program Plan:

  • Create a class called Account.
  • Add a method called withdraw that accepts a double type of variable and checks if the balance is greater than withdraw amount.
  • Then subtract the withdrawl amount from balance otherwise print a message "Withdrawl amount exceeded account balance".
  • Create a class AccountTest
  • Create an instance of Account constructor with name and initial balance.
  • Prompt for withdrawl amount from the Account object.
  • Call withdraw method on Account class object.
  • Print results account balance after calling withdraw method.

Blurred answer
Students have asked these similar questions
(Person Class) Design a class named Person that contains: o name, gender, and personCase as a private attribute o Non-default constructor that specifies name and gender o toString method that returns person data o personCase () method with no implementation (Student Class) Design a class named Student which is a child of Person that contains: o studentID as a private attribute o Nondefault constructor that specifies the name, gender, and studentID o toString method that returns student data o Implement personCase () that assigns "Not Studying" to personCase if studentID equals 0, “Studying" in case studentID greater than 0, and "Not a student" in case studentID less than 0. (Employee Class) Design a class named Employee which is a child of Person that contains: o employeelD as a private attribute o Non-default constructor that specifies the name, gender, and employeelD o toString method that returns employee data o Implement personCase () that assign “Technical" to personCase if…
(Account class)Create an Account class that a bank might use to represent customers’ bank accounts. Include a data member of type int to represent the account balance. Provide a constructor that receives an initial balance and uses it to initialize the data member. The constructor should validate the initial balance to ensure that it’s greater than or equal to 0. If not, set the balance to 0 and display an error message indicating that the initial balance was invalid. Provide three member functions. Member function credit should add an amount to the current balance. Member function debit should withdraw money from the Account and ensure that the debit amount does not exceed the Account’s balance. If it does, the balance should be left unchanged, and the function should print a message indicating "Debit amount exceeded account balance." Member function get_Balance should return the current balance. Create a program that creates two Account objects and tests the member functions of class…
2. Import Classa) Implement a class Rectangle with two attributes, width and height. b) Implement an init method with an optional parameter type. Set the default value of the attributes of width and height to 1.c) Implement a display method to print the values of width and height.d) Implement a setWidth method to assign width to the instance variable.e) Implement a setHeight method to assign height to the instance variable.f) Implement a getWidth method to return the value of the instance variable width.g) Implement a getHeight method to return the value of the instance variable height.h) Implement an area method to return the value of area of a rectangle.i) Save Rectangle class as rectangle.py.j) Import Rectangle class from rectangle.py.k) Employs the Rectangle class methods above to set and get various measurements of a rectangle. 1) Instantiate two objects of type rectangle, one with arguments one without. r1 = Rectangle(4, 5)r2 = Rectangle() 2) Call display() to print width and…

Chapter 3 Solutions

Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)

Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education