Great Deal! Get Instant \$10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

1. Stock Commission. An investor buys shares of stock at a particular price per share through their stockbroker. The investor must pay their stockbroker a commission for the transaction. The...

1. Stock Commission. An investor buys shares of stock at a particular price per share through their stock
oker. The investor must pay their stock
oker a commission for the transaction. The commission paid to the stock
oker is a flat rate of 4.25% of the total cost of the shares. Write a program that when given the number of shares purchased and the share price will calculate and display the following:
Â· The amount paid for the stock alone (without the commission)
Â· The amount of the commission
Â· The total amount paid (for the stock plus the commission)
a) Â Plan a solution by producing an IPO chart for the problem and an initial algorithm. b) Â Convert your algorithm into a Java program. The name of the class file should be StockCommission. Compile and test your code in Eclipse.
c) Â Modify your algorithm in part a to ensure that the user cannot enter an invalid number of shares, share price, or commission rate. Number of shares must be between 100 and XXXXXXXXXXShare price must be greater than \$0 but less than or equal to \$500.00.
XXXXXXXXXXd) Â Update your Java program to incorporate the validation from part c
2. Number Statistics.
Write a program that lets the user enter a series of decimal numbers (ie, numbers that may have a decimal point) that lie in the range -50,000 to 50,000. The user should enter 0 to signal the end of the series. The program must count the number of positive and negative numbers entered. After all the numbers have been entered by the user, the program should display the number of numbers entered, the total of the positive numbers, the total of the negative numbers, the average of the negative numbers, the average of the positive numbers, the average of all positive and negative numbers combined, and the largest and smallest numbers. Ensure that the sentinel value is not included in any of the statistics. The Scanner class must be used for keyboard input.
Note: Plan a solution by producing an IPO chart and an initial algorithm for the problem, then write and test the Java source code.
Class file name: The name of the class file should be Statistics
3. Koala Population.
Write a program that will predict the size of a koala population over time (years). The program should ask for the starting number of koalas, their average annual population increase (as a percentage), and the number of years they will multiply. For example, a koala population might begin with 1000, have an average annual increase of 2 percent, and allowed to multiply for twelve years. The program must display the predicted size of the koala population for each year. Do not accept a number less than 500 for the initial size of the population. Do not accept a negative number for average annual population increase (note: average annual population increase already includes koala deaths due to old age, disease, predatory hunting, natural disasters, etc). Do not accept a number less than 10 for the number of years the population will multiply. The Scanner class must be used for keyboard input.
Note: Plan a solution by producing an IPO chart and an initial algorithm for the problem, then write and test the Java source code.
Class file name: The name of the class file should be Koala
3. Stock Commission. Copy your code solution Stock Commission from question 1, into your project. Modify your solution to incorporate appropriate methods utlising appropriate parameter passing. The functional requirements are the same (including the validation of shares and share price) except, the commission rate must be entered by the user in the range 1 to 5.5%.
Answered Same Day Aug 20, 2021

Solution

Neha answered on Aug 21 2021
63740 - java cde/Koala.java
63740 - java cde/Koala.java
importÂ java.util.Scanner;
publicÂ classÂ Koala
{
Â Â Â Â publicÂ staticÂ intÂ getInt(ScannerÂ input,Â intÂ lower,Â intÂ upperÂ ,Â StringÂ sÂ )
Â Â Â Â {
Â Â Â Â Â Â Â Â intÂ val;
Â Â Â Â Â Â Â Â while(true)
Â Â Â Â Â Â Â Â {
Â Â Â Â Â Â Â Â Â Â Â Â valÂ =Â input.nextInt();
Â Â Â Â Â Â Â Â Â Â Â Â if(lowerÂ <=Â valÂ &&Â valÂ <=Â upper)
Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â returnÂ val;Â Â Â
Â Â Â Â Â Â Â Â Â Â Â Â System.out.println(sÂ +Â "Â shouldÂ lieÂ betweenÂ "Â +Â lowerÂ Â +Â "Â andÂ "Â +Â upper);
Â Â Â Â Â Â Â Â }
Â Â Â Â Â Â
Â Â Â Â }
Â Â Â Â
Â Â Â Â
Â Â Â Â publicÂ staticÂ voidÂ printStats()
Â Â Â Â {
Â Â Â Â Â Â Â Â ScannerÂ inputÂ =Â newÂ ScannerÂ (System.in);Â Â
Â Â Â Â Â Â Â Â System.out.println(Â "EnterÂ initÂ sizeÂ ofÂ population"Â );
Â Â Â Â Â Â Â Â intÂ popSizeÂ =Â getInt(inputÂ ,Â 500Â ,Â Integer.MAX_VALUEÂ ,Â "KoalaÂ population");
Â Â Â Â Â Â Â Â System.out.println(Â "EnterÂ averageÂ populationÂ increase"Â Â );
Â Â Â Â Â Â Â Â intÂ popIncÂ =Â getInt(inputÂ ,Â 0Â ,Â 100Â ,Â "PercentageÂ Increase");
Â Â Â Â Â Â Â Â System.out.println(Â "EnterÂ yearsÂ populationÂ canÂ increase"Â );
Â Â Â Â Â Â Â Â intÂ yearCountÂ =Â getInt(inputÂ ,Â 10Â ,Â Integer.MAX_VALUEÂ ,Â "YearÂ count");
Â Â Â Â Â Â Â Â
Â Â Â Â Â Â Â Â doubleÂ popIncDÂ =Â (double)popInc;
Â Â Â Â Â Â Â Â popIncDÂ =Â popIncDÂ /Â 100.0;
Â Â Â Â Â Â Â Â doubleÂ finalSizeÂ =Â popSizeÂ +Â Math.pow((1.0Â +Â popIncD)Â ,Â (double)yearCountÂ );
Â Â Â Â Â Â Â Â System.out.println(Â "FinalÂ sizeÂ ofÂ population"Â +Â (int)finalSizeÂ );
Â Â Â Â Â Â Â Â
Â Â Â Â }
}
63740 - java cde
eport.docx
1. Stock Commission
Input
Process
Output
Cost of shares
Number of shares
Calculate total price of shares and amount after the commission
Amount paid for stock
Commission
Total amount including commission
Algorithm
Ask user to enter number of shares.
Ask user to enter amount of shares
Print amount paid for stock by multiplying the number of shares and cost of each share.
Print commission
Print total amount paid including commission
2. Number Statistics
Input
Process
Output
List of positive and negative integers
Perform statistics on negative and positive integers
Number of numbers entered
Number of positive integers
Number of negative integers
Average of positive integers
Average of negative integers
Average of all positive and negative integers
Largest numbe
Smallest numbe
Algorithm