Instructions: Revise Lab 3: Calc.java program (Stocks). Calculate the amount paid and sold for stock shares. Change the program to use a class name “Stock” The “Stock” class should have an instance...

Instructions: Revise Lab 3: Calc.java program (Stocks). Calculate the amount paid and sold for stock shares. Change the program to use a class name “Stock” The “Stock” class should have an instance variable in the constructor int shares set equal to the value passed to the constructor. (See the Lab Revision-Stock section of this document). Submit for a grade: Lab3 RevisedStock.java Here’s a similar code used in Lab 3 Calc import java.util.Scanner; public class StockReport{ public static void main(String[] args){final double PURCHASE = 31.77, SELL = 40.25; int shares; double paid, sold, net; Scanner scan = new Scanner(System.in); System.out.println("\n Stock Report \n"); System.out.print(" Enter number of shares: "); shares = scan.nextInt();paid = shares * PURCHASE; sold = shares * SELL; net = sold - paid; System.out.println("\n Amount paid = " + paid);System.out.println(" Amount sold = " + sold); System.out.println(" Net = " + net);}} Change the program to use a class named Stock. The Stock class has this instance variable in the constructor. int shares set equal to the value passed to the constructor. Stock class contains these methods. Calc Amt Paid calculates and returns the amount paid for the stock. calcAmtSold calculates and returns the amount received for the sale of the stock. The main driver (StockReport.java): Requests the number of shares from the user. Instantiates the object. Calls the Stock class to calculate the amount paid. Calls the Stock class to calculate the amount received. Calculates the net loss or gain. Displays the amount paid, amount received and the net loss or gain.
May 19, 2022
SOLUTION.PDF

Get Answer To This Question

Submit New Assignment

Copy and Paste Your Assignment Here