Question: I need the code further below to be modified to the prompts directly below. Log-in and password need to be used to enter the stock

I need the code further below to be modified to the prompts directly below. Log-in and password need to be used to enter the stock calculator.

Some parts of the code just have to be deleted or re-written to follow the prompt.

________________________________________________________

YEE-TRADE, INC. - The Wild West of Electronic Trading Welcome to Yee-Trade's stock purchase calculator. What is your name? Hawkeye Pierce Enter your log-in: Buffett2011

Enter your password: Rank1Bill2008 Invalid log-in or password! 1 attempt left. Enter your log-in: Buffet2011 Enter your password: Rank1Bill2008 Do you want to calculate your stock purchases? Enter 'Y' or 'N' to exit: y How many shares did you purchase? l000

You must only enter an integer for the number of shares: 1000 What is the price per share? 1t

You must only enter a double for the share price: 15 Is this an online trade? Enter 'Y' or 'N': y

Enter 'Y' to calculate the cost of another stock purchase or 'N' to exit: y How many shares did you purchase? 500 What is the price per share? 52 Is this an online trade? Enter 'Y' or 'N': n

Is this a broker assisted trade? Enter 'Y' or 'N': y Enter 'Y' to calculate the cost of another stock purchase or 'N' to exit: y How many shares did you purchase? 50 What is the price per share? 52 Is this an online trade? Enter 'Y' or 'N': n Is this a broker assisted trade? Enter 'Y' or 'N': n INVALID TRADE TYPE! Enter 'Y' to calculate the cost of another stock purchase or 'N' to exit: n

YEE-TRADE, INC. TOTAL COST OF STOCK PURCHASES FOR Hawkeye Pierce AS OF OCTOBER 18, 2018

Total Stock Cost: $41,000.00 Total Online Fees: $5.95 Total Commissions: $520.00

TOTAL COST: $41,525.95 Thank you for using Yee-Trade's stock purchase calculator!

_____________________________________________________

import java.util.*;

public class Mich15

{

public static void main(String[] args)

{

processTrades();

}//

public static String setPersonName(Scanner input)

{

System.out.println("What is your first and last name?");

return input.nextLine();

}

public static String setStockName(Scanner input)

{

System.out.println("What is the name of your stock?");

return input.nextLine();

}

public static int setShares(Scanner input)

{

System.out.println("How many shares did you purchase?");

return input.nextInt();

}

public static double setPricePerShare(Scanner input)

{

System.out.println("What is the price per share?");

return input.nextDouble();

}

public static char setOnlineTrade(Scanner input)

{

System.out.println("Is this an online trade? Enter 'Y' or 'N':");

return input.next().toUpperCase().charAt(0);

}

public static char setBrokerAssisted(Scanner input) {

System.out.println("Is this a broker assisted trade? Enter 'Y' or 'N': ");

return input.next().toUpperCase().charAt(0);

}

public static char setAnotherStock(Scanner input)

{

System.out.println("Do you want to process another trade? Enter 'Y' or 'N':");

return input.next().toUpperCase().charAt(0);

}

public static char setAnotherPerson(Scanner input)

{

System.out.println("Will trades continue for another person? Enter 'Y' or 'N':");

return input.next().toUpperCase().charAt(0);

}

public static String prepareOnlineFee(String stockName, int shares, double sharePrice, double stockCost, double onlineFee, double commission, double totalCost)

{

return String.format("Stock: %s ", stockName)

+ String.format("No. of Shares: %d ", shares)

+ String.format("Price Per Share: $%.2f ", sharePrice)

+ String.format("Cost of Stock: $%.2f ", stockCost)

+ String.format("Online Fee: $%.2f ", onlineFee)

+ String.format("Commission: $%.2f ", commission)

+ String.format("Total Cost: $%.2f ", totalCost) + " ";

}

public static String prepareBrokerAssisted(String stockName, int shares, double sharePrice, double stockCost, double onlineFee, double commission, double totalCost) {

return String.format("Stock: %s ", stockName)

+ String.format("No. of Shares: %d ", shares)

+ String.format("Price Per Share: $%.2f ", sharePrice)

+ String.format("Cost of Stock: $%.2f ", stockCost)

+ String.format("Online Fee: $%.2f ", onlineFee)

+ String.format("Commission: $%.2f ", commission)

+ String.format("Total Cost: $%.2f ", totalCost) + " ";

}

public static void processTrades()

{

String stockName;

String personName;

int shares;

double sharePrice;

double stockCost;

double commission = 0.00;

double totalCost = 0;

double onlineFee = 5.00;

Scanner input = new Scanner(System.in);

Calendar dateTime;

char anotherTrade = 'Y';

char anotherPerson = 'Y';

boolean invalidTrade = false;

String stockPurchases = "";

while (anotherPerson == 'Y')

{// takes in the person name and date of stocks

personName = setPersonName(input);

anotherTrade = 'Y';

dateTime = Calendar.getInstance();

stockPurchases = "STOCK PURCHASES FOR " + personName + " AS OF " + dateTime.getTime() + " ";

while (anotherTrade == 'Y')

{

// resetting total cost

totalCost = 0.00;

// Taking inputs

stockName = setStockName(input);

shares = setShares(input);

sharePrice = setPricePerShare(input);

// Calculations

stockCost = sharePrice * shares;

totalCost += stockCost;

if (setOnlineTrade(input) == 'Y')

{

onlineFee = 5.95;

totalCost += onlineFee;

// zero out commission

commission = 0.00;

stockPurchases = stockPurchases + prepareOnlineFee(stockName, shares, sharePrice, stockCost, onlineFee, commission, totalCost);

}

else

{

if (setBrokerAssisted(input) == 'Y')

{

onlineFee = 0.00;

commission = stockCost * 0.02;

totalCost += commission;

stockPurchases = stockPurchases + prepareBrokerAssisted(stockName, shares, sharePrice, stockCost, onlineFee, commission, totalCost);

}

else

{

// invalid trade

System.out.println("INVALID TRADE TYPE! Exiting program.");

anotherTrade = 'N';

invalidTrade = true;

stockPurchases = "";

}

}

if (anotherTrade != 'N')

{

anotherTrade = setAnotherStock(input);

input.nextLine();

}//clears input buffer

}

if (invalidTrade)

anotherPerson = 'N';

else

{

anotherPerson = setAnotherPerson(input);

System.out.println(stockPurchases);

input.nextLine();

}

}

input.close();

}//END PROCESS TRADES

}//END APPLICATION

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!