The example code keeps track of the change in stock price after each trading day. A user enters the buying price and the closing price on subsequent trading days. Then the earnings are evaluated. The process stops when a negative closing price is entered.
You'll learn most by trying my code while watching the video.
Please post your improvement on my code on the comments.
Concepts:
While loop
Break command
If-Else statement
Scanner class
DecimalFormat class
Playlist of my Java course
https://www.youtube.com/playlist?list=PLtQo0sxRN7JLr647f8RTzS58u8Rv5jxT5
Playlist of my Java examples
https://www.youtube.com/playlist?list=PLtQo0sxRN7JKKla3_GAF05dySjyy3nINa