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
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));
}
}
Get Answers For Free
Most questions answered within 1 hours.