Company stock in c ++

Zamknięty Opublikowano Apr 9, 2015 Płatność przy odbiorze
Zamknięty Płatność przy odbiorze

FILE READING AND WRITING

1. Create a file named [login to view URL] consisting of following data:

Apple AAPL 450.00

Boeing BA 75.50

Intel INTC 22.30

Rambus RMBS 5.55

Sirius SIRI 3.15

Skyworks SWKS 25.35

Xilinx XLNX 36.80

The first column is the company names. The second column contains the company stock symbols. The last column contains the stock prices.

2. Create a file named [login to view URL] consisting of following data:

Leon1111 5000.00

Wise2222 10000.00

Woo3333 3000.00

White4444 7000.00

Head5555 4000.00

The first column is the account ID. The second column contains the available cash to buy stocks.

3. Write a program doing the followings:

· Define a structure named SStock including the following data items:

o company typed string.

o symbol typed string

o price typed double

· Create an array of SStock and read the stock information from the file [login to view URL] into that array.

· Define a structure named SAccount including the following data items:

o id typed string.

o cash typed double

· Create an array of SAccount and read the stock information from the file [login to view URL] into that array.

· Define one function for searching a stock in the stock array. The function should return the index of the found stock or -1 if not found.

· Define one function for searching a account in the account array. The function should return the index of the found account or -1 if not found.

· Have a menu including:

o 3 main options for listing, buying and selling stocks.

o Check the available cash of an account

o Quit

· For listing, list all of the information of all stocks.

· For buying, remember to check if the buyer has enough money to buy.

· For any transaction, remember to update the available cash of the account.

· Create a new output file named [login to view URL] to keep all of the records of selling or buying. When a transaction happens , record the transaction into the output file with the following information: time, account ID, type of transaction, stock symbols, price and number of shares. When buying, check if the account has enough money to buy. For selling, however, there should be no checking for any condition.

Example of [login to view URL]:

Sat Mar 16 17:49:41 2015 White4444 buy BA 75.5 50

Sat Mar 16 17:49:55 2015 Woo3333 buy AAPL 450 40

Sat Mar 16 17:50:12 2015 Wise2222 sell NOK 3.35 100

Sat Mar 16 17:50:33 2015 Leon1111 sell SIRI 3.25 1000

Note: You can add this function into your program to get the current time:

#include <time.h>

....

string getCurrentTime ()

{

time_t rawtime;

struct tm * timeinfo;

time (&rawtime);

timeinfo = localtime (&rawtime);

char timeStr[100];

char tempStr[100];

strcpy(tempStr, asctime(timeinfo));

int len = strlen(tempStr);

strncpy_s(timeStr, tempStr, len - 1);

return string (timeStr);

}

Pisanie raportów

Numer ID Projektu: #7459436

O projekcie

2 ofert Zdalny projekt Aktywny May 17, 2015

2 freelancerów złożyło ofertę za $286 w tym projekcie

pavi87june

Hi there, I am an experienced academic writer with excellent research skills. I can assure you gilt-edged quality and plagiarism free work. I have worked on multiple academic assignments including literature Więcej

$526 USD w ciągu 4 dni
(395 Oceny)
7.6