Create a class called StockTester that has the following fucntionality. a. Create a main method with an ArrayList named dataStock that stores objects of type Stock. b. Add code that reads the content of StockInfo.csv and places it in dataStock. c. Create a new Stock object named newStock using the constructor in Question 1. Set the values to the following. Stock name: Gamma, Stock purchase date: 03/01/20, Number of Shares of Stock: 100, Stock Price: 50.5. Add newStock to dataStock. d. Print the information associated with newStock using printStock. e. Using the method requiredReturn, determine the rate of return required for your stock in Pitsco to have a value of $4,000 in 3 years. Print the result to the screen so that the user can clearly read the result.

Answers

Answer 1

Solution :

public class [tex]$\text{Stock}$[/tex] {

private [tex]$\text{String}$[/tex] stockName, [tex]$\text{purchaseDate}$[/tex];

private [tex]$\text{int}$[/tex] nShares;

private [tex]$\text{double}$[/tex] price;

 

public [tex]$\text{Stock}()$[/tex]

{

this.stockName = "";

this.purchaseDate = "";

this.nShares = 0;

this.price = 0.0;

}

public Stock(String stockName, String purchaseDate, int nShares, double price) {

this.stockName = stockName;

this.purchaseDate = purchaseDate;

this.nShares = nShares;

this.price = price;

}

public String getStockName() {

return stockName;

}

public void setStockName(String stockName) {

this.stockName = stockName;

}

public String getPurchaseDate() {

return purchaseDate;

}

public void setPurchaseDate(String purchaseDate) {

this.purchaseDate = purchaseDate;

}

public int getnShares() {

return nShares;

}

public void setnShares(int nShares) {

this.nShares = nShares;

}

public double getPrice() {

return price;

}

public void setPrice(double price) {

this.price = price;

}

 

public String toString()

{

return("Stock name: " + this.stockName + "\nPurchase date: " + this.purchaseDate

+ "\nNumber of shares of stock: " + this.nShares + "\nPrice: $" + String.format("%,.2f", this.price));

}

 

public void printStock()

{

System.out.println("Stock name: " + this.stockName + "\nPurchase date: " + this.purchaseDate

+ "\nNumber of shares of stock: " + this.nShares + "\nPrice: $" + String.format("%,.2f", this.price)

+ "\n");

}

}

StockTester.java (Driver class)

import [tex]$\text{java.io.}$[/tex]File;

import [tex]$\text{java.io.}$[/tex]File[tex]$\text{NotFound}$[/tex]Exception;

import [tex]$\text{java.util.}$[/tex]ArrayList;

import [tex]$\text{java.util.}$[/tex]Scanner;

[tex]$\text{public}$[/tex] class StockTester {

 

private static final String FILENAME = "StockInfo[tex]$.$[/tex]csv";

 

public static [tex]$\text{void}$[/tex] main([tex]$\text{String}[]$[/tex] args)

{

ArrayList[tex]$<\text{stock}>$[/tex] dataStock = [tex]$\text{readData}$[/tex](FILENAME);

 

System.out.println("Initial stocks:");

for(Stock s : dataStock)

s.printStock();

 

System.out.println("Adding a new Stock object to the list..");

Stock newStock = new Stock("Gamma", "03/01/20", 100, 50.5);

dataStock.add(newStock);

 

System.out.println("\nStocks after adding the new Stock..");

for(Stock s : dataStock)

s.printStock();

 

Stock targetStock = dataStock.get(3);

double reqReturn = requiredReturn(targetStock, 4000, 3);

System.out.println("Required rate of return = " + String.format("%.2f", reqReturn) + "%");

}

 

private static ArrayList<Stock> readData(String filename)

{

ArrayList<Stock> stocks = new ArrayList<>();

Scanner fileReader;

try

{

fileReader = new Scanner(new File(filename));

while(fileReader.hasNextLine())

{

String[] data = fileReader.nextLine().trim().split(",");

String stockName = data[0];

String purchaseDate = data[1];

int nShares = Integer.parseInt(data[2]);

double price = Double.parseDouble(data[3]);

 

stocks.add(new [tex]$\text{Stock}$[/tex](stockName, [tex]$\text{purcahseDate}$[/tex], nShares, price));

}

fileReader.close();

}catch(FileNotFoundException fnfe){

System.out.println(filename + " cannot be found!");

System.exit(0);

}

return stocks;

}

 

private static double requiredReturn(Stock s, double targetPrice, int years)

{

double reqReturn;

 

double initialPrice = s.getPrice() * s.getnShares();

reqReturn = ((targetPrice - initialPrice) / initialPrice * years) * 100;

 

return reqReturn;

}

}


Related Questions

Using a tag, set the color to green for all tags.

Answers

Answer:

<style>

p {

background-color: rgb(255, 0, 0);

}

h1 {

background-color: rgb(0, 255, 0);

}

ol {

background-color: rgb(97,51,47);

}

</style>

Explanation:

Put this at the top of your code. It should target the paragraph tag, the header h1 tag, and the Ordered List (OL) tag individually and set their background colors respectively.

It's been a while since I've done CSS so you might have to tweak the syntax a bit, but it should look something like that.

How SPARQL 1.1 has advantage over SPARQL 1.0??​

Answers

SPARQL 1.0 became an official W3C Recommendation on 15 January 2008. On 26 March 2013, the SPARQL Working Group has produced a new W3C Recommendation SPARQL 1.1 that introduces more features to 2008 version. SPARQL is emerging as the de facto RDF query language. Prior to SPARQL, there were some other popular RDF query languages, such as RQL, SeRQL, TRIPLE, RDQL, and so on. The comprehensive...

Please Fix This For Me


print ("Please enter a number between 1 and 100")
n = input

if = n < 1 and n > 100:

if = (n // 2 == 0):
print (n, "is even")

if = (n // 3 == 0):
print (n, "is odd")

else:
print("You have not entered a number between 1 and 100.")

Answers

Answer:

The correction is as follows:

n = int(input("Please [tex]enter\ a[/tex] [tex]number\ between\ 1[/tex] and 100: "))

if n < 1 or n > 100:

   print("You [tex]have\ not[/tex] entered a [tex]number\ between\ 1[/tex] and 100.")

elif n % 2 == 0:

   print (n, "is even")

else:

   print (n, "is odd")

Explanation:

See attachment for explanation

63. Name the 4 main lights & and their primary purpose.

Answers

I don’t know this !!

Which of the following is not part of the four ways you can avoid problems with email communication?
a.
Be brief.
b.
Proofread your message.
C.
Reply right away after you get an email.
d.
Seek other ways to relay your message

Answers

Answer:

d is the correct answer for this problem

When identifying who will send a presentation, what are the two types of audiences?

Answers

Answer:

Explanation:Demographic audience analysis focuses on group memberships of audience members. Another element of audience is psychographic information, which focuses on audience attitudes, beliefs, and values. Situational analysis of the occasion, physical setting, and other factors are also critical to effective audience analysis.

Consider the following method:
public static String joinTogether(int num, String[] arr)
{
String result = "";
for (String x : arr)
{
result = result + x.substring(0, num);
}
return result;
}

The following code appears in another method in the same class:
String[] words = {"dragon", "chicken", "gorilla"};
int number = 4;
System.out.println(joinTogether(number, words));

What is printed when the code above is executed?
a. dragonchickengorilla
b. drachigor
c. dragchicgori
d. dragochickgoril
e. There is an error in the program, it does not run

Answers

Answer: b.

Explanation:

how many stages needed to have powerful amplifier?​

Answers

Power amplifier stages in a real circuit. Circuit diagram of a three stage practical audio power amplifier is shown in the figure below. Small signal transistor Q1 and its associated components form the voltage amplification stage.

Answer:

Generally you should pick an amplifier that can deliver power equal to twice the speaker's program/continuous power rating. This means that a speaker with a “nominal impedance” of 8 ohms and a program rating of 350 watts will require an amplifier that can produce 700 watts into an 8 ohm load.

Other Questions
Which food item does not fit the group?For example: If you see cookie, cake, chicken you would select "chicken" because it is not adessert.lechequesomanzana match the eukaryotic kingdom with the approrite descriptionhelp meeeeeeeee Can someone help me with this short 5 question assignment Is 11 pronounced eleven or onety-one?? PLS HELP MOM WILL SMAK ME WITH A CLOCK AGAIN PLS HELP If you want to make 174 grams of NiFz, how many moles of HF will you need, usingthe following balanced chemical equation? Ni + 2 HF - NiF2 + H2 Below are the simplified current and projected financial statements for Decker Enterprises. All of Decker's assets are operating assets. All of Decker's current liabilities are operating liabilities. Income statement Current Projected Sales na 1,500 Costs na 1,080 Profit before tax na 420 Taxes (25%) na 105 Net income na 315 Dividends na 95 Balance sheets Current Projected Current Projected Current assets 100 115 Current liabilities 70 81 Net fixed assets 1,200 1,440 Long-term debt 300 360 Common stock 500 500 Retained earnings 430 650 If Decker had a financing deficit, it could remedy the situation by a. borrowing from retained earnings b. borrowing on its line of credit c. paying down its long-term debt d. buying back common stock e. paying a special dividend PQR has angle measurements of 80, 50, and 50. What kind of triangle is PQR? Which is an example of internal conflict? *1 The dog was foaming at the mouth and snarling. Suddenly, it lunged at me!2 I'm not speaking to Jenna until she apologizes to me. But I miss her so much! 5+5(6*7)Easy points cause I love yall pur Shelly's age plus Mary's age is less than 36. Mary is 15 years old. Write the equation thatrepresents the problem. If I add 25mL of water to 125 mL of 0.25 M NaOH solution, what will the molarity of the diluted solution be? La natalidad hace que la poblacin aumenta o disminuya?? Students in a school are asked to pick either football, rugby or tennis to play in their lesson.The number of students who picked football and rugby are in the ratio of 5:4The number of students who picked rugby and tennis are in the ratio of 12:25125 students picked tennis.Work out how many students picked football. what language is this? , , , , Nitric acid and nitrogen monoxide react to form nitrogen dioxide and water, like this: (aq)(g)(g)(l) At a certain temperature, a chemist finds that a reaction vessel containing a mixture of nitric acid, nitrogen monoxide, nitrogen dioxide, and water at equilibrium has the following composition: compoundamount Calculate the value of the equilibrium constant for this reaction. Round your answer to significant digits. Which precipitation and vegetation descriptions best fit an Aw climate in the Kppen classification? Which precipitation and vegetation descriptions best fit an Aw climate in the Kppen classification? Well-defined winter dry season; savanna with drought-tolerant trees Every month has 6 cm of precipitation or more; lush tropical vegetation At least 10 times as much precipitation in a summer month as the driest winter month; vegetation short and thick Well-defined summer dry season; vegetation sparse Short dry season, precipitation of driest month has less than 6 cm but equal to or greater than 10-R/25; thick green vegetation Interrupting before the patient has finished speaking shows that you are not listening to them.Group of answer choicesTrueFalse Listen and read. Which T-shirt does the girl buy?Have you got this T-shirt in blue?we have what size are yourHow's tIt's great, How much is it?It's EMediumHere you areThank you. Can I try it on?anging room is over there,Here you areThanThank you76.50L 10.25XS 5.32bs 6.50bXL 7.75bachorten 1) Hank is looking to sell his motorcycle. He compiles these prices from the newspaper for bikes just like his$2,000; $ 16,900; $15,100; $14,500; and $17,000. Is it more reasonable for Hank to use the mean or themedian to get a reasonable estimated price for his bike? You are a business developer and charge $45 for a site visit plus additional $24 per hour for each hour you spend training employees. Write and solve an equation to determine how many total hours you have to work to earn $810 working hours at two separate businesses.