Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

STOCK PROGRAM: public class Stock { private String Symbol; private String name; private double previousClosingPrice; private double currentPrice; Stock(String symbol, String name) { this.Symbol =

STOCK PROGRAM:

public class Stock { private String Symbol; private String name; private double previousClosingPrice; private double currentPrice; Stock(String symbol, String name) { this.Symbol = symbol; this.name = name; }

public String getSymbol() { return Symbol; }

public void setSymbol(String symbol) { Symbol = symbol; }

public String getName() { return name; }

public void setName(String name) { this.name = name; } public double getChangePercent() { return ((currentPrice - previousClosingPrice) * 100) / currentPrice; }

public void setPreviousPrice(double previous) { previousClosingPrice = previous; }

public void setCurrentPrice(double current) { currentPrice = current; }

}

STOCK TEST PROGRAM:

import java.util.Scanner;

public class StockTest { public static void main(String [] argv){ Scanner input = new Scanner(System.in); System.out.println("Please input the stock symbol: "); String symbol = input.nextLine(); System.out.println("Please input the stock name: "); String name = input.nextLine(); Stock stock = new Stock(symbol, name); // set the previous price System.out.println("Please set the previous price: "); stock.setPreviousPrice(input.nextDouble()); // set the current price System.out.println("Please set the current price: "); stock.setCurrentPrice(input.nextDouble()); System.out.println("Price Change percetage of stock is :" + stock.getChangePercent() +"% "); } }

Following the instructions in the problem statement, design and implement a Java program for programming exercise 9.2, page 360 (name it Stock.java).

Next, develop a test program in a separate file (call it TestStock.java) to create object ORCL as stated in the problem statement. Now, modify the test program to create 2 more stock objects (say MS and Google) and test all class methods on these 2 objects in logical order and display meaningful information after each method call. Document your code, and organize and space the outputs properly. Use escape characters and formatting objects when applicable.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing Fundamentals Design

Authors: Marion Donnie Dutton Don F. Seaman

14th Edition Globel Edition

1292107634, 978-1292107639

More Books

Students also viewed these Databases questions

Question

10. Are the trade-offs inherent in supplier selection understood?

Answered: 1 week ago

Question

How many Tables Will Base HCMSs typically have? Why?

Answered: 1 week ago

Question

What is the process of normalization?

Answered: 1 week ago