Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

To become familiar with Java language basics (variable declaration, numeric expr

ID: 3843501 • Letter: T

Question

To become familiar with Java language basics (variable declaration, numeric expression, assignment statement, input using Scanner, and formatting output). Write a program to accept inputs from a user including yourName, numberShares shares (only whole shares allowed) purchased of some stock (for example the Microsoft stock symbol is MSFT) at the price of buyPrice per share and paid the stockbroker $15 buyTransactionFee. Two weeks later, the person sold the numberShares shares at sellPrice per share and paid another $10 for the sellTransactionFee. Create the necessary input, process and output variables, choosing appropriate data types, and write a Java program to accept input, calculate and display the following: dollar amount paid for the shares dollar amount of the shares sold total transaction fee paid to the broker (including both buy and sell) - Use constants/final amount of profit (or loss) made after selling the shares. yourName, numberShares. buyPrice. sellPrice Sample Run (user's inputs are shown in bold): What's your name? Joseph What stock are you purchasing? MSFT How many shares bought? 250 Buy price? 28.31 Sale price? 30.79 Using Java to get the inputs above. Calculate and generate the following formatted Output:

Explanation / Answer

Please enter your First Name:   ds
Please enter the MPG of your car:   20
Please enter the miles to be traveled:   24
What is the price per gallon of gas:   2
Hello ds! Thank you for providing your information!
Car MPG:   20
Miles to Drive:   24
Price per gallon of gas:   $2.0
Your trip will cost:   $2.4

Please enter your First Name:   Ralph
Please enter the MPG of your car:   30
Please enter the miles to be traveled:   60
What is the price per gallon of gas:   3.0

HelloRalph! Thank you for providing your information!
Car MPG:   30
Miles to Drive:   60
Price per gallon of gas:   $3.0
Your trip will cost:   $6.0


Please enter your First Name:   Darshan
Please enter the MPG of your car:   5
Please enter the miles to be traveled:   20
What is the price per gallon of gas:   20

Hello Darshan! Thank you for providing your information!
Car MPG:   5
Miles to Drive:   20
Price per gallon of gas:   $20.0
Your trip will cost:   $80.0

Output:

What’s your name?    darshan
What stock are you purchasing?    google
How many shares bought?    20
Buy price?    10
Sale price?    12
Number of shares purchased:   $20
Amount of purchase:   $200.0
Amount of sale:   $240.0
Transaction fees paid::   $25.0
Net profit:   $15.0

What’s your name?    dsd
What stock are you purchasing?    mst
How many shares bought?    100
Buy price?    10
Sale price?    15
Number of shares purchased:   $100
Amount of purchase:   $1000.0
Amount of sale:   $1500.0
Transaction fees paid::   $25.0
Net profit:   $475.0


What’s your name?    ama
What stock are you purchasing?    amazon
How many shares bought?    4
Buy price?    20
Sale price?    23
Number of shares purchased:   $4
Amount of purchase:   $80.0
Amount of sale:   $92.0
Transaction fees paid::   $25.0
Net profit:   $-13.0

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote