EBK JAVA PROGRAMMING
9th Edition
ISBN: 9781337671385
Author: FARRELL
Publisher: CENGAGE LEARNING - CONSIGNMENT
expand_more
expand_more
format_list_bulleted
Question
- A private int data field named accountNum for the account (default 0).
- A private string data field named accountName for the account (default "none").
- A private double data field named balance for the account (default 0).
- A private int data field named numTransactions that will count the number of deposit and withdraw transactions made to an account.
- A private Date data field named dateCreated that stores the date when the account was created.
- A no-arg constructor that creates a default account.
- A constructor that creates an account with the specified account number and name.
- The accessor and mutator methods for account number, name.
- The accessor method for balance and dateCreated.
- A method named withdraw that withdraws a specified amount from the account.
- A method named deposit that deposits a specified amount to the account.
- A method named displayAccountInfo that displays all the information in the Account object.
- A method named combine that takes another Account object as an argument and adds up balances and number of transactions to current Account object.
package assignment2;
public class Test {
public static void main(String[] args) {
Account account = new Account(1122, "my checking account");
account.deposit(3000);
account.withdraw(2500);
account.deposit(800);
account.withdraw(200);
account.displayAccountInfo();
if (account.getBalance() != 1100) {
System.out.println("Something went wrong! " + account.getAccountName() + " should have 1100 CAD balance.");
}
System.out.println();
Account accountSavings = new Account(1133, "my savings account");
accountSavings.deposit(10000);
accountSavings.deposit(2000);
accountSavings.displayAccountInfo();
System.out.println();
account.combine(accountSavings);
account.setAccountNum(1190);
account.setAccountName("my all money at the bank");
account.displayAccountInfo();
}
}
"Test.java" and below output is expected:
Account num: 1122
Account name: my checking account
Balance: 1100.0 CAD
4 transactions since created at Thu Jul 06 12:55:20 PDT 2023
Account num: 1133
Account name: my savings account
Balance: 12000.0 CAD
2 transactions since created at Thu Jul 06 12:55:21 PDT 2023
Account num: 1190
Account name: my all money at the bank
Balance: 13100.0 CAD
6 transactions since created at Thu Jul 06 12:55:20 PDT 2023
Account name: my checking account
Balance: 1100.0 CAD
4 transactions since created at Thu Jul 06 12:55:20 PDT 2023
Account num: 1133
Account name: my savings account
Balance: 12000.0 CAD
2 transactions since created at Thu Jul 06 12:55:21 PDT 2023
Account num: 1190
Account name: my all money at the bank
Balance: 13100.0 CAD
6 transactions since created at Thu Jul 06 12:55:20 PDT 2023
USE PDT time, makes sure the code is right
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by stepSolved in 2 steps with 1 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
- Requirement: A private int data field named accountNum for the account (default 0). A private string data field named accountName for the account (default "none"). A private double data field named balance for the account (default 0). A private int data field named numTransactions that will count the number of deposit and withdraw transactions made to an account. A private Date data field named dateCreated that stores the date when the account was created. A no-arg constructor that creates a default account. A constructor that creates an account with the specified account number and name. The accessor and mutator methods for account number, name. The accessor method for balance and dateCreated. A method named withdraw that withdraws a specified amount from the account. A method named deposit that deposits a specified amount to the account. A method named displayAccountInfo that displays all the information in the Account object. A method named combine that takes another Account…arrow_forwardRequirement: A private int data field named accountNum for the account (default 0). A private string data field named accountName for the account (default "none"). A private double data field named balance for the account (default 0). A private int data field named numTransactions that will count the number of deposit and withdraw transactions made to an account. A private Date data field named dateCreated that stores the date when the account was created. A no-arg constructor that creates a default account. A constructor that creates an account with the specified account number and name. The accessor and mutator methods for account number, name. The accessor method for balance and dateCreated. A method named withdraw that withdraws a specified amount from the account. A method named deposit that deposits a specified amount to the account. A method named displayAccountInfo that displays all the information in the Account object. A method named combine that takes another Account…arrow_forward"song1": { "genre": "g1", "album": "a1", "rating": "r1", "other": "some data1" The songs.json }, "song2": { "genre": "g2", "album":"a2", "rating": "r2", "other": "some data2" }, "song3": { "genre": "g3", "album": "a3", "rating": "r3", "other": "some data3" }, "song4": { "genre": "g4", "album":"a4", "rating": "r4", "other": "some data4" } }arrow_forward
- PYTHON CLASSES AND OBJECT (The Stock class) Design a class named Stock to represent a company’s stock that contains: ■A private string data field named symbol for the stock’s symbol. ■A private string data field named name for the stock’s name. ■A private float data field named previousClosingPrice that stores the stockprice for the previous day. ■A private float data field named currentPrice that stores the stock price for the current time. ■A constructor that creates a stock with the specified symbol, name, previousprice, and current price. ■A get method for returning the stock name. ■A get method for returning the stock symbol. ■Get and set methods for getting/setting the stock’s previous price. ■Get and set methods for getting/setting the stock’s current price. ■A method named getChangePercent() that returns the percentage changed from previous ClosingPrice to currentPrice.Write a test program that creates a Stock object with the stock symbol INTC, the name Intel Corporation, the…arrow_forwardThe Inventory class contains a Private variable named strId. The variable is associated with the Public ItemId property. An application instantiates an Inventory object and assigns it to a variable named onHand. Which of the following can be used by the application to assign the string "XG45 to the strId variable? a. onHand.ItemId = "XG45" b. ItemId.strId = "XG45" c. onHand.strId = "XG45" d. ItemId.strId = "XG45"arrow_forwardCreate an application named SalesTransactionDemo that declares several SalesTransaction objects and displays their values and their sum. The SalesTransaction class contains fields for a salesperson name, sales amount, and commission and a readonly field that stores the commission rate. Include three constructors for the class. One constructor accepts values for the name, sales amount, and rate, and when the sales value is set, the constructor computes the commission as sales value times commission rate. The second constructor accepts a name and sales amount, but sets the commission rate to 0. The third constructor accepts a name and sets all the other fields to 0. An overloaded + operator adds the sales values for two SalesTransaction objects.arrow_forward
- Design an application that tracks airline flights. The Flight Schedule is the most important part of the application, which is a collection of flights. Each flight has several attributes, including the Airline and the Aircraft information. The Airline is identified by a name, such as Delta Air, and a code for all of its flights, such as DL. For simplicity, you can assume that every airline has a fleet of one particular type of aircraft. This allows the user to enter only the airline code to fill the rest of the aircraft data when the flight data is entered into the system. Flight Schedule Design: Define the structure for the Flight Schedule. Identify data fields for Airline Name, Airline Code, Aircraft Name/Model, Seat Capacity, and Class-specific seat numbers. Identify data fields for each flight, including Airline Code, Flight number, Flight status, and Flight Type. Define Departure data fields: Day-of-the-week, Departure Time, Airport Code, Departure Gate. Define Arrival data…arrow_forwardCreate the StockTask1 Java project Create a Stock object class that contains the following information: The symbol of the stock is stored in a private string data field called symbol. The stock's name is stored in a private string data field called name. previousClosingPrice is a private double data area that stores the stock price for the previous day. currentPrice is a private double data area that stores the stock price at the current time. A constructor for creating a stock with the given symbol and name. For the data fields, there are accessor methods (get-methods). For the data fields, there is a mutator method (set-methods). A method named getChangePercent()that returns the percentage changed from previousClosingPrice to currentPrice. Formula:perc_change = (current price - previous closing price) / previous closing price x 100 Create a test class named testStockthat creates a Stockobject with the stock symbol SUNW, the name Sun Microsystems Inc., and the previous closing…arrow_forwardAfter executing the following piece of code: z = 25 + 10j print(z.real) z = "apple" print(z.imag) what will we get? Select one: A. 10 0 B. 25 AttributeError Traceback (most recent call last) in () 3 z="apple" ----> 4 print(z.imag) AttributeError: 'str' object has no attribute 'imag' C. 25 0arrow_forward
- //Global Constant Global Constant TECH_FEE = 0.05 Module main () //Local Variable Declare Integer studentID, ClassTitles , hoursWorked, numofClass, techFee, totalBill classCost=$150 //Get Student ID Call getStudentID () //Get Class Titles Call getCLassTitles () End Module Module getStudentID () Display "Please enter your Student ID:" Input studentID End Module Module getClassTitles () //Get number of class student wants to add and calculate the total bill Display "One class will be free if you add three classes." Display "How many classes do you want to take? (Limit 3)" Input numofClass if numofClass > 3 then Display "Error: Maximum of 3 Class Allowed" end if while numofClass <= 3 if numofClass == 1 then Display "Please enter the Class Title" Input class1 Set classCost = 150 * numofClass Set techFee = classCost * TECH_FEE Set totalBill = classCost +…arrow_forwardAn object is an ordered collection of properties. Question 9 options: True Falsearrow_forwardIf the compiler encounters a statement that attempts to modify the value of a constant field, an error will result. True or False.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTEBK JAVA PROGRAMMINGComputer ScienceISBN:9781305480537Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTProgramming with Microsoft Visual Basic 2017Computer ScienceISBN:9781337102124Author:Diane ZakPublisher:Cengage Learning
- Programming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:CengageMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781305480537
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:9781337102124
Author:Diane Zak
Publisher:Cengage Learning
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,