Write a Java program to print the net asset value for shares

Write a Java program to print the net asset value for shares held by a user.   
The program will read data from a file called “GOOGprices.csv” to retrieve the date and value per share (adjCose). The only columns of interest in this comma separated value file are the first and the last column. These are the “Date” column and the “Adj Close” column respectively. We can find the totalValue by:

totalValue      =      numberOfShares      *   adjClose

The numberOfShares will be retrieved as a user input when the program begins. The totalValue must be represented with two decimal places. We are not concerned with rounding errors/inaccuracies.

Example program output Welcome to the Asset Management Systerm Input the number of GOoG shares: 2 Your GOOG assets: Number of Shares 2 2 2 2 Date 10/24/16 10/21/16 10/20/16 10/19/16 10/18/16 10/17/16 10/14/16 10/13/16 10/12/16 10/11/16 Total Value 1626.22 1598.74 1593.94 1603.06e 1590.52 1559.92 1557.06 1556.38 1572.28 1566.14 2 2 2 2 2 Goodbye!

Solution

#include #include #include #include #include using namespace std; // Determines if the string is a number bool isNumeric(string pszInput); int main () { // Hold the line in the file string line; // Open the file ifstream myfile (\"example.txt\"); if (myfile.is_open()) { // While the file is good while (myfile.good() ) { // Get the current line in the file getline (myfile, line); // Verify that the line is an integer if (isNumeric(line)) { // Convert \'line\' to an integer and calculate if (atoi(line.c_str())%2 == 0) { cout << \"Even\ \"; } else { cout << \"Odd\ \"; } } } myfile.close(); } else { cout << \"Unable to open file\ \"; } // Exit return 0;
Write a Java program to print the net asset value for shares held by a user. The program will read data from a file called “GOOGprices.csv” to retrieve the date

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site