Question

A. STOCK COMMISSION Suppose the customer first name is Mary and last name is Jones. :...

A. STOCK COMMISSION

Suppose the customer first name is Mary and last name is Jones.

: i. Declare firstName and lastname string variables that hold a first and last name.

ii. Declare a sharesOfStock int variable that holds a value of 750

iii. Declare a pricePerShare double variable that holds a value of 35.00

iv. Declare a commissionRate double variable that holds .02 (which is 2%)

v. Description: Assume that the person listed in the fName and lName variables purchased the amount of stock stored in sharesOfStock at the price stored in pricePerShare. She must pay a stockbroker the commisionRate percentage for the transaction. Write a program that calculates and displays:

1. The amount paid for the stock alone (without commission)

2. The amount of commission

3. The total amount paid for the stock, including the commission

4. Make sure and use appropriate labels

Homework Answers

Answer #1


public class Stock {
   public static void main(String[] args) {
       String firstName = "Mary";
       String lastName = "Jones";
       int sharesOfStock = 750;
       double pricePerShare = 35;
       double commissionRate = 0.02;
       //finding the amount paid only to the stock
       double totolStock = (sharesOfStock * pricePerShare);
       //finding the commission
       double commission = totolStock * commissionRate;
       // displaying all the details
       System.out.println("The Amount Paid for Stock : " + totolStock);
       System.out.println("The Amount of Commisio : " + commission);
       System.out.println("Total Amount : " + (totolStock + commission));
   }
}

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
WRITE A JAVA PROGRAM 1. Assignment Description Write a stock transaction program that calculates a customer's...
WRITE A JAVA PROGRAM 1. Assignment Description Write a stock transaction program that calculates a customer's profit (or loss) within a certain period of time. 1) First, the program need to get user's name, the stock's code, number of shares and the price he/she purchased the stock, it also asks the user for the price he/she sold the stock later on. The program then compute the following: The amount of money the customer paid for the stock. The amount of...
COSC 1436 Programming Assignment 2 Programming Assignment 2 Refactoring is the process of taking existing code...
COSC 1436 Programming Assignment 2 Programming Assignment 2 Refactoring is the process of taking existing code and improving its design without changing the functionality. In this programming assignment, you are going to take your code from Programming Assignment 1 and refactor it so that it uses functions. The program should still do the following:  Get the name of a student  Get the name of three assignments  Get the grade of three assignments as integers  Calculates the...
Code Example 8-1 1. int count = 1; 2. int item_total = 0; 3. int item...
Code Example 8-1 1. int count = 1; 2. int item_total = 0; 3. int item = 0; 4. while (count < 4) { 5.      cout << "Enter item cost: "; 6.      cin >> item; 7.      item_total += item; 8.      ++count; 9. } 10. int average_cost = round(item_total / count); 11. cout << "Total cost: " << item_total << "\nAverage cost: " << average_cost; (Refer to Code Example 8-1.) If the user enters 5, 10, and 15 at the prompts, the output is: Total...