Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

How do I get the commission to output a percent and assign the commission rate the value of 2%? It just says error the way

How do I get the commission to output a percent and assign the commission rate the value of 2%? It just says error the way it is.

image text in transcribedimage text in transcribed

image text in transcribed

* purchase price of one share (float) * sale price of one share (float) The broker will charge commission fee rate 2% on the total of the purchase shares money and on the total of the sale shares money After calculating, the application must display the result on the screen in 11 output lines in the following format with the name and numbers should be aligned to the right and with 2 decimal digits. Notes: You must complete reading input before displaying the output and write the comments for each task (not for each line of the code) The formula to calculate the profit from the investment are: PURCHASE Buying shares money = purchase price of share unit number of shares Commission fee on buying = Buying shares money purchase commission rate Total of invested money= Buying shares money + commission fee on buying dcccd school docs - SP2023_LAB2PART1_Kaldawi/src/SP2023_SharesInvestment_Kaldawi.java - Eclipse IDE Edit Source Refactor Navigate Search Project Run Window Help (1) SP2023_SharesInvestment_Kaldawi.java Writable Source Refactor Navigate Search Project Run Window Help 2023_Shareslnvestment_Kaldawi.java float SaleCommission; float Totalinvestment; float TotalinvestmentBack; float Totalprofit; / / name System.out.println("Please enter the investor's name: "); name = keyboard. nextLine () ; / / Purchase System. out.println("Please enter the number of shares you would like to buy: "); Shares = keyboard. nextint () ; System. out.println("Please enter the purchase price per share: "); PurchasePricePershare = keyboard. nextFloat (); TotalPurchase = Shares * Purchasepricepershare; PurchaseCommission = CommissionRate * TotalPurchase; Totalinvestment = TotalPurchase + PurchaseCommission; / /Sale System.out.println("Please enter the sale price per share: "); Salepricepershare = keyboard.nextFloat (); Totalsale = SalePricePershare * Shares; SaleCommission = CommissionRate * Totalsale; TotalinvestmentBack = TotalSale - SaleCommission; TotalProfit = TotalinvestmentBack - Totalinvestment; / /output System. out.println("File: SP2023_ShareInvestment_Kaldawi.java + "Spring 2023 semester - Jeanette Kaldawi \ n" " System. out.println (String.format("\%-15s\%15s", "Name of Investor:", name)); System. out.println (String.format("\%-15s\%15d", "Number of shares:", Shares)); System. out.println (String.format("\%-15s\%15.2f", Commission Rate:", CommissionRate)); System. out.println(String.format("\%-15\%15.2f", "Purchase price of each share:", PurchasePricePershare)) ; System. out.println (String.format("\%-15s\%15.2f", "Money Invested:", Totalinvestment)); System. out.println (String. format("\%-15s\%15.2f", "Sell Stock Price:", SalePricePershare)); System. out.println (String.format("\%-15s\%15.2f", "Money returned from Investment:",TotalinvestmentBack)); System. out. println ("---------------------------------------------") ; \} \}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advanced Database Systems

Authors: Carlo Zaniolo, Stefano Ceri, Christos Faloutsos, Richard T. Snodgrass, V.S. Subrahmanian, Roberto Zicari

1st Edition

155860443X, 978-1558604438

More Books

Students also viewed these Databases questions