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 answer below »
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
118 Votes
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
Ask user to enter multiple...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here