Skip to content

Latest commit

 

History

History
36 lines (34 loc) · 2.09 KB

README.md

File metadata and controls

36 lines (34 loc) · 2.09 KB

Investment Tracker App

This code is for a simple investment tracking application that calculates daily and total earnings of an investment over 7 days period.

How it works:

  1. The user is prompted to enter the buying price per share.
  2. The user is then prompted to enter the closing price for each day of the week (7 days).
  3. For each day, the application calculates the earnings by subtracting the buying price from the closing price.
  4. The earnings are stored in an array weekly.
  5. The application then prints out a message indicating whether the investment has gained, lost, or broken even for each day.
  6. After all 7 days, the application calculates the total weekly earnings by summing up the earnings for each day.
  7. The total weekly earnings are printed out to the console.

Variables and Data Structures:

  • buyingPrice: The buying price per share.
  • closingPrice: The closing price for each day.
  • weekly: An array of doubles to store the earnings for each day.
  • day: An integer variable to keep track of the current day.
  • i: An integer variable to iterate through the weekly array.
  • j: An integer variable to iterate through the weekly array in the second loop.
  • totalWeeklyEarnings: A double variable to store the total weekly earnings.

Methods:

  • Scanner to read input from the user.
  • System.out.println and System.out.printf to print output to the console.
  • Arrays to store and manipulate the weekly array.

Code Output On Console:

image