Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Need help getting this code to compile. import java.util.Scanner;//input from user import java.util.Calendar;//determines date public class BYU2016 { public static void main(String[] args) { System.out.printf(%nYEE-TRADE,INC.-

Need help getting this code to compile.

import java.util.Scanner;//input from user

import java.util.Calendar;//determines date

public class BYU2016

{

public static void main(String[] args)

{

System.out.printf("%nYEE-TRADE,INC.- The Wild West of Electronic Trading"

+ "%n%nWelcome to Yee-Trade's stock purchase calculator %n"); //print 1

}

public static string setCustName(Scanner input) {

System.out.printf("%nWhat is your name? ");

return input.nextLine();}

public static string login(Scanner input) {

System.out.printf("%nEnter your log-in: ");

return input.nextLine();

}

public static string password(Scanner input) {

System.out.printf("%nEnter your password: ");

return input.nextLine(); }

public static int setShares(Scanner input) {

System.out.printf("%nHow many shares did you purchase? ");

return input.nextInt(); }

public static double setSharePrice(Scanner input) {

System.out.printf("%nWhat is the price per share? ");

return input.nextDouble(); }

public static char onlineTrade(Scanner input) {

System.out.printf("%nIs this an online trade? Enter \'Y\' or \'N\' : ");

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

public static double onlineFees() {

onlineFee = 5.95;

totalOnlineFees = totalOnlineFees + onlineFee;

totalCost = totalCost + onlineFee;

return totalCost; }

public static char brokerTrade (Scanner input) {

System.out.printf("%nIs this a broker assisted trade? Enter 'Y' or 'N': ");

return brokerAssisted; }

public static double commissions (double stockCost) {

commission = stockCost * .02;

totalCommissions = totalCommissions + commission;

totalCost = totalCost + commission;

return totalCost;}

public static char another (Scanner input) {

System.out.printf("%nEnter 'Y' to calculate the cost of another stock purchase or 'N' to exit: ");

another = input.nextLine().charAt(0);} //prompts the user for any calculations left

public static String displayFinalCost( String customerName, String date, double totalStockCost, double totalOnlinefees, double totalCommissions, double totalCost) {

{ System.out.printf("%nYEE-TRADE,INC.%nTOTAL COST OF STOCK PURCHASES"+

"%nFOR %s" +

"%nAS OF %s" +

"%n%nTotal Stock Cost: $%,.2f" + //output 2

"%nTotal Online Fees: $%,.2f" +

"%nTotal Commissions: $%,.2f" +

"%n%nTOTAL COST: $%,.2f", customerName, date, totalStockCost, totalOnlineFees, totalCommissions, totalCost);

}

for (attempts = 1; attempts >0; attempts--) {

login(input);

password(input);

if(login.equals("Buffet2011") && password.equals("Rank1Bill2008"))

{

while (another == 'Y'){

totalCost= 0.0;

shares = setShares(input);

sharePrice = setSharePrice(input);

stockCost = shares * sharePrice; //calculations 1,2,3

totalStockCost = totalStockCost + stockCost;

totalCost = totalCost + stockCost;

} // end while

} // end if login

if(onlineTrade = 'Y') {

onlineFee = 5.95; //set online fee to 5.9

totalOnlineFees = totalOnlineFees + onlineFee; //calculations 5 6

totalCost = totalCost + onlineFee;

} // end if online trade

else {

if(brokerTrade = 'Y') {

commission = stockCost * .02; //calculations 7 8 9

totalCommissions = totalCommissions + commission;

totalCost = totalCost + commission;

} // end if brokerTrade

else { System.out.printf("%nINVALID TRADE TYPE%n"); // prompts that cusotmer has said no to both statements

noOfStocks = noOfStocks - 1;

totalStockCost = totalStockCost - stockCost;// calculations 10,11,12

totalCost = totalCost - stockCost;

} // end else

System.out.printf("%nEnter 'Y' to calculate the cost of another stock purchase or 'N' to exit: ");

another = input.nextLine().charAt(0); //asks if there needs to be another calculations

}

if(noOfStocks > 0) //only does if noOfStocks is less then 0

{

System.out.printf("%nYEE-TRADE,INC.%nTOTAL COST OF STOCK PURCHASES"+

"%nFOR %s" +

"%nAS OF %s" +

"%n%nTotal Stock Cost: $%,.2f" + //output 2

"%nTotal Online Fees: $%,.2f" +

"%nTotal Commissions: $%,.2f" +

"%n%nTOTAL COST: $%,.2f", customerName, date, totalStockCost, totalOnlineFees, totalCommissions, totalCost);

}

noOfStocks=0;

}

{

if(attempts >= 2) //shows how many attempts are left.

{

System.out.printf("%nInvalid log-in or password! %d attempts left. ",attempts); //shows invalid log in attempt message

}

else

{

switch(attempts)// switch for while loop

{

case 1:

System.out.printf("%nInvalid log-in or password! %d attempts left. ",attempts);

break;

default:

System.out.printf("%nNo more attempts left! Contact technical support at 1-800-111-2222 ");

break;

}

}

}

}

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

Step: 3

blur-text-image

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

Spatio Temporal Database Management International Workshop Stdbm 99 Edinburgh Scotland September 10 11 1999 Proceedings Lncs 1678

Authors: Michael H. Bohlen ,Christian S. Jensen ,Michel O. Scholl

1999th Edition

3540664017, 978-3540664017

More Books

Students also viewed these Databases questions

Question

4. How can speakers manage speaking anxiety?

Answered: 1 week ago

Question

Question Who can establish a Keogh retirement plan?

Answered: 1 week ago