All pastes #398095 Raw Edit

;lkj

public cpp v1 · immutable
·published 2007-03-16 23:03 UTC
rendered paste body
#include <iostream>#include <fstream>using namespace std;float numberofshares;float price;float totalprice(float numberofshares, float price);int main(){    char date[255];    char symbol[255];    char buysell[255];    char filelines[255];    //open the file    ofstream stocks( "stocks.txt" );    cout<<"Enter the date of the transaction: ";    cin.getline(date, 255);    cin.get();    cout<<"Enter the symbol: ";    cin.getline(symbol, 255);    cin.get();    cout<<"What you did(buy, sell, etc): ";    cin.getline(buysell, 255);    cin.get();    cout<<"Number of shares you bought: ";    cin>> numberofshares;    cin.get();    cout<<"Price of the stock you bought: ";    cin>> price;    cin.get();    stocks<< date << " " << symbol << " " << buysell << " " << numberofshares << " " << price << " " << totalprice(numberofshares , price ) <<"\n" << endl;    stocks.close();    //open file to read    ifstream stock( "stocks.txt" );    stock>> filelines;    cin.get();            return 0;}float totalprice(float numberofshares, float price){            return numberofshares * price;}