PROGRAM INSTRUCTIONS:
1. Code an application that asks the customer for alog-in and password. 2. The real log-in is \"Buffet2011\" and thereal password is \"Rank1Bill2008\". 3. Allow the customer two (2)attempts to type either.
a. Each time the customer enters an invalid log-in orpassword issue an error message.
b. If the customer fails all two (2) log-in attempts,issue another error message and exit the program.
c. If the log-in is successful, the customer cancalculate the cost of multiple trades, so there can be acombination of online and broker assisted trades.
4. Ask the customer if it's an online trade, if socharge $5.95 for the trade; otherwise, ask if it's a brokerassisted trade, if so then charge a 2% brokerage fee. If not thenprint an error message, and let the customer try again. Keep trackof the number of stocks for which trades are beingmade.
5. Logical Control Structures from PA1:
a. Use a while loop to process for multiple stock tradesin a given transaction. Use a sentinel controlled loopvariable.
b. Use if-else, nested if-else and if structures tofigure out
i. whether it is an online trade or broker assistedtrade;
ii. when to print the error message \"INVALID TRADETYPE!\"
iii. when to print the final output with the totalcalculations for stock cost, online fees, commissions, and overallcost.
c. The customer can calculate for multiple stockpurchases as long as the customer has more purchases to calculate.The calculated stock cost is added to a total for stock cost andthe overall total (total cost); the online fee is added to a totalfor online fees and the overall total; and, the commission is addedto a total for commissions and the overall total. Use printf() withformat specifiers where needed.
d. Don’t forget to insert the exit statement at the endof main().
e. The prompts, the final output specs, and the sampleoutput show you in what order to place your code. To return fromthese links press Alt then left arrow.
6. Logical Control Structures for PA2: This program isthe same as PA1 EXCEPT:
a. There are additional prompts for the login andpassword.
b. Both the login and password must be correct toproceed.
c. You’ll use a do-while loop to control the number ofattempts.
d. Use an if-else to test the attempts left, so theproper message is displayed for more than 2 attempts left, 1attempt left and no more attempts left. Embed a switch to test forattempts less than or equal to 1.
e. There are 3 new variables.
7. Program Logic: NO plan for this PA.
a. The prompts tell you what input variables you willneed.
b. The output will tell you the type of calculations youwill need (if any) and whether you will need to declare additionalvariables.
c. The output will tell you the order of logic for yourcode.
8. Work and submit this program on your own (nopartner). Name your program asYourLastNameFirstInitialYourSectionNoPA2.
9. Commenting Your Program:
a. In your program, YOU MUST insert a program purpose inthe first comment box. The content of that first comment box wasshown to you in the Anatomy of a Java Program lecture for chapter1.
b. Use Javadoc comment boxes beginning with /** andending with */ for your comment boxes.
c. Insert a Javadoc comment box above your methodsexplaining what is going on in the method that goes for the main()which is a method.
d. Line comment the import statements and the variablesdeclared at the class level and/or in any method [includingmain()].
10. Formatting Rules: Refer to the Java Style Guideposted on Blackboard in IS 2033. Always test your output tovalidate that your program is functioning properly with the correctoutput and spacing (line advances and spacing after punctuation).The %n can function differently when using separate printfstatements versus one printf.
PROMPTS: Code the bold from the prompts below in theprintf statements that capture data into your program. Once again,the prompts tell you your input variables.
Welcome Message: Prints before prompt for customername.
YEE-TRADE, INC. - The Wild West of ElectronicTrading
Welcome to Yee-Trade's stock purchasecalculator. Â
1st Prompt:Â Â
What is your name? Â
2nd Prompt: Beginning with this prompt, the majority ofthe code will be nested in the do-while mentioned in 2cabove. Â
Enter your log-in:Â Â
3rd Prompt: If the entries from the 2nd and 3rd promptsmatch the real log-in and password proceed to the 4th prompt elseprint the error message(s). Â
Enter your password:Â Â
Error Message When Log-In & Password Incorrect: Oneof these error messages will be displayed every time the log-in orpassword is incorrect. The 9 represents the number of attempts leftout of two (2). You’ll accommodate in the code for the possibilityof more than 2 attempts.
Invalid log-in or password! 9 attempts left. ? Use when>= 2 attempts left Invalid log-in or password! 9 attempt left. ?Use when 1 attempt left
Error Message When No More Attempts Left: This errormessage will be displayed when there are no more attempts left, andthe program will terminate. This is NOT a forced exit. The codeshould automatically sequence to the exit statement at the end ofmain(). Â
No more attempts left! Contact tech nical support at1-800-111-2222. Â
4th Prompt: This prompt will display after the customerenters the correct log-in and password within the allotted 2attempts. The value captured from this prompt is the loop-controlvariable for the sentinel-while loop mentioned in 1a of the ProgramInstructions section above. Â
Do you want to calculate your stock purchases? Enter 'Y'or 'N' to exit: If the answer is anything other than ‘Y’, the whileloop is by-passed and this message is displayed: Thank you forusing Yee-Trade's stock purchase calculator!
5th Prompt: Prompts 5 through 9 will be in asentinel-controlled while loop. Â
How many shares did youpurchase? Â
6th Prompt:Â Â
What is the price per share? Â
7th Prompt: If the answer to this prompt is 'Y' add a5.95 online trading fee to the stock cost then go to the 9thprompt, else go to the 8th prompt. Also, refer to 1c for additionalcalculation instructions.
Is this an online trade? Enter 'Y' or'N':Â Â
8th Prompt: This prompt will display only when theanswer to the 7th prompt is 'N'. If the answer to this prompt is'Y', calculate the commission by assessing a 2% brokerage fee onthe stock cost then go to the 9th prompt, else proceed to the errormessage. Â
Is this a broker assisted trade? Enter 'Y' or'N':
Error Message When Trade is Neither Online or BrokerAssisted: If the answer is 'N', print this error message thenproceed to the 9th prompt.
\"INVALID TRADE TYPE!\"Â Â
9th Prompt: If the answer is 'Y' then you'll go back tothe 5th prompt. This is the same loop-control variable in prompt4.
Enter 'Y' to calculate the cost of another stockpurchase or ‘N’ to exit: Â
If the answer is anything other than ‘Y’, the while loopis exited, the final output is displayed along with thismessage:
Thank you for using Yee-Trade's stock purchasecalculator!
Original Code:
/**
* @(#)004PA1.java
* @author
* version 1.00 2020/09/23
*
* PROGRAM PURPOSE: This program controls whether
* a customer can calculate the cost of
* their stock purchase
*/
import java.util.Scanner;
import java.util.Calendar;
public class 004PA1
{
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
Calendar dateTime = Calendar.getInstance();
String date = String.format(\"%1$TB %1$TD, %1$TY\", dateTime);
 Â
String customerName = null;
int shares = 0, noOfStocks = 0;
double sharePrice = 0.0,
stockCost = 0.0,
commission = 0.0,
totalCost = 0.0,
onlineFee = 0.0,
totalStockCost = 0.0,
totalCommissions = 0.0,
totalOnlineFees = 0.0;
char onlineTrade = ' ',
brokerAssisted = ' ',
another = 'N';
 Â
System.out.printf(\"%nYEE-TRADE, INC. - The Wild West of ElectronicTrading%n\"
+ \"%nWelcome to Yee-Trade\'s stock purchase calculator. %n\");
System.out.printf(\"%nWhat is your name? \");
customerName = input.nextLine();
System.out.printf(\"%nDo you want to calculate your stock purchases?\"
+ \"Enter\'Y\' or \'N\' to exit: \");
another = input.nextLine().charAt(0);
 Â
while(Character.toUpperCase(another) == 'Y')
{
noOfStocks = noOfStocks + 1;
 Â
System.out.printf(\"%nHow many shares did you purchase? \");
shares = input.nextInt();
 Â
System.out.printf(\"%nWhat is the price per share? \");
sharePrice = input.nextDouble();
stockCost = shares * sharePrice;
totalStockCost += stockCost;
totalCost += stockCost;
 Â
input.nextLine();
 Â
System.out.printf(\"%nIs this an online trade? \"
+ \"Enter \'Y\' or \'N\': \");
onlineTrade = input.nextLine().charAt(0);
 Â
if(Character.toUpperCase(onlineTrade) == 'Y')
{
onlineFee = 5.95;
totalOnlineFees += onlineFee;
totalCost += onlineFee;
}
else
{
System.out.printf(\"%nIs this a broker assisted trade? \"
+ \"Enter \'Y\' or \'N\': \");
brokerAssisted = input.nextLine().charAt(0);
 Â
if(Character.toUpperCase(brokerAssisted) == 'Y')
{
commission = stockCost * .02;
totalCommissions = totalCommissions + commission;
totalCost = totalCost + commission;
}
else
{
System.out.printf(\"%nINVALID TRADE TYPE!\");
noOfStocks = noOfStocks - 1;
totalStockCost = totalStockCost - stockCost;
totalCost = totalCost - stockCost; Â Â
} Â Â
}
System.out.printf(\"%nEnter 'Y' to calculate the cost of anotherstock purchase \"
+ \"or 'N' to exit: \");
another = input.nextLine().charAt(0);
}
if (noOfStocks > 0)
{
System.out.printf(\"%nYEE-TRADE,INC.\"
+ \"%nTOTAL COST OF STOCK PURCHASES \"
+ \"%nFOR \" + customerName
+ \"%nAS OF \" + date
+ \"%nTotal Stock Cost: $\" + totalStockCost
+ \"%nTotal Online Fees: $\" + totalOnlineFees
+ \"%nTotal Commissions: $\" +totalCommissions
+ \"%nTOTAL COST: $\" + totalCost);
}
System.out.printf(\"%nThank you for using Yee-Trade's stock purchasecalculator!\");
noOfStocks = 0;
 Â
System.exit(0);
}
}