
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
(Java)
- Create a new project folder in Eclipse for this activity.
- In this folder, create two new classes - Account.java and Savings.java and put your name in a Javadoc comment at the top.
- Make the Account class an abstract class by adding the abstract keyword before the class keyword
- Inside the Account class, add the following variables and methods:
- A private variable called name (String)
- A private variable called balance (double)
- A two-argument constructor which takes in String and double parameters
- A no argument constructor, which calls the two-argument constructor, passing in "name unknown" and 0.0 as arguments.
- Getter and setter methods for the two variables
- An abstract method called updateBalance
- A toString() method
- Make the Savings class final by adding the final keyword before the class keyword - now this class cannot be extended (no inheritance from this class).
- Also make Savings a subclass of Account
- Inside the Savings class, add the following variables and methods:
- A private variable called interestRate (double)
- A three-argument constructor which takes in a String and two double parameters, and calls the two argument constructor of the Account class
- A no argument constructor, which calls the three-argument constructor of Savings, passing in "name unknown", 0.0, and 0.0 as arguments.
- Getter and setter methods for the interestRate variable
- A method called updateBalance that overrides the abstract method of the super class
- Note that it is required to override this method or your class will have an error
- This method is void and has no parameters
- It multiplies balance by 1 + interestRate and assigns the result to balance
- A toString() method that overrides toString from the superclass.
- Add a final class to your project folder called SavingsTest.java. Copy and paste the below code into this class.
/**
* SavingsTest.java
* @author
* CIS 36B, Activity 13.1
*/
import java.util.Scanner;
public class SavingsTest {
public static void main(String args[]) {
Scanner input = new Scanner(System.in);
System.out.println("Welcome!\n");
System.out.print("Enter your name: ");
String name = input.nextLine();
System.out.print("Enter the balance to invest: $");
double balance = input.nextDouble();
System.out.print("Enter the interest rate on your target account: ");
double interest = input.nextDouble();
Savings savings = new Savings(name, balance, interest);
System.out.println("\nHere is your account summary: \n" + savings);
savings.updateBalance();
System.out.printf("In one year, your balance"
+ " will be: $%.2f", savings.getBalance());
input.close();
}
}
* SavingsTest.java
* @author
* CIS 36B, Activity 13.1
*/
import java.util.Scanner;
public class SavingsTest {
public static void main(String args[]) {
Scanner input = new Scanner(System.in);
System.out.println("Welcome!\n");
System.out.print("Enter your name: ");
String name = input.nextLine();
System.out.print("Enter the balance to invest: $");
double balance = input.nextDouble();
System.out.print("Enter the interest rate on your target account: ");
double interest = input.nextDouble();
Savings savings = new Savings(name, balance, interest);
System.out.println("\nHere is your account summary: \n" + savings);
savings.updateBalance();
System.out.printf("In one year, your balance"
+ " will be: $%.2f", savings.getBalance());
input.close();
}
}
- When your program works as shown in the sample output, upload Account.java and Savings.java to Canvas.
Sample Output:
Welcome!
Enter your name: Grace Kang
Enter the balance to invest: $50000
Enter the interest rate on your target account: .025
Here is your account summary:
Name: Grace Kang
Balance: $50000.0
Interest Rate: 0.025
In one year, your balance will be: $51250.00
Expert Solution

arrow_forward
Introduction
- Create a new project folder in Eclipse for this activity.
- In this folder, create two new classes - Account.java and Savings.java and put your name in a Javadoc comment at the top.
Trending nowThis is a popular solution!
Step by stepSolved in 5 steps with 5 images

Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- Can you show me an example in java. I am a beginner programmer.arrow_forwardMaking sure that encapsulation is not violated (i.e., instance variables must be private); design an inheritance hierarchy of classes Car, Truck, and Vehicle based on the following description. Car is a Vehicle. Truck is a Vehicle. (a) Definition of class Vehicle Instance variables: year that holds the year of vehicle (int) make that holds the make of vehicle (string) Methods: a default constructor with no arguments. a second constructor that accepts the Vehicle's year and the make as arguments. These values should be assigned to the object's instance variables: year and make. A copy constructor that accepts an existing vehicle object reference as argument and copies the values of instance variables to the newly created object. Accessor methods (getYear() and getMake()) that get the values of instance variables. Mutator methods (setYear(int) and setMake(String)) that set the values of instance variables. toString() should return a…arrow_forwardHello, I don’t understand this Java Question may someone help me out, may you also submit the completed code typed out the code in text form please instead of a screenshot of a screenshot ?arrow_forward
- Please help me with the question using Java. Please use compliment to explain each line of code.arrow_forwardCan you give me the solution in javaarrow_forward1) Write a class on BlueJ, which must be called BookClub. The class must have exactly three fields: two integer fields called capacity and occupancy and one String field called name. The capacity field will store the maximum number of shoppers allowed and occupancy will store the current number of shoppers. (There must be no additional fields defined in the class, even if you think more are required. Consider using local variables inside methods if you think you need extra fields.) 2) The initial values of the book club name, and capacity must be received as parameters to the class's constructor, while the occupancy must always be set to zero when a BookClub object is created. 3) The class must define getter methods for all of the fields. These must be called getName, getCapacity and getOccupancy. You must not call them anything different. You must not write setter methods for the fields. The class must define a method called addOne that takes no parameters. If the current number of…arrow_forward
- please do both parts 1)Create two Java classes, Desktop and Laptop that both are subclasses of Computer.a) A Desktop has additional instance variables: width and height (data encapsulation isexpected)b) A Laptop has an additional instance variable, weight (data encapsulation is expected).c) Write constructors for both classes that require input for all their instance variables(including Manufacturing Date, Disk size, Number of cores and Color) and no-argsconstructors.d) Create getters and setters for all instance variables for both Child classes.e) Create toString() methods in Desktop and Laptop. 2) Test Two Child ClassesTest your newly created subclasses inside the same TestComputer program you previouslycreated: create two new Laptops and two new Desktops with the data of your choice. UsetoString() method to show all data fields (including the data fields in the super class and sub class).arrow_forwarda) How do you declare an object’s reference variable? What does it store? b) When will a class have a default constructor? How do you create a default constructor in Eclipse?arrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education

Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON

Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education