Hello all I'm new to this forum, and I have been trying to get my coding to allow me to read the saved data from a file into the console window, and it doesn't seem to be working. Any advice on what I should add to this existing coding so I can read the saved info...Thanks in advance for all your advice...
#include <iostream>
#include <fstream>
#include <iomanip>
#include <string>
#include <stdio.h>
#include <windows.h>
using std::ios;
using std::ofstream;
using std::ifstream;
usingnamespace std;
int main()
{
SetConsoleTitle(("Money Tracker V 2.1"));
int menuchoice=0;
float bal=0.0;
float secondbankbal=0.0;
float income=0.0;
float rent=0.0;
float insurance=0.0;
float cellphone=0.0;
float net=0.0;
float gas=0.0;
float ui=0.0;
float creditcard=0.0;
float creditcard2=0.0;
float firsttally=0.0;
float sectally=0.0;
float thitally=0.0;
float frthtally=0.0;
float fifthtally=0.0;
float sixthtally=0.0;
float billtotal=0.0;
float leftovertally=0.0;
float newtally=0.0;
float seventhtally=0.0;
float eigthtally=0.0;
string date=" ";
ofstream savings;
cout<<endl;
cout<<endl;
cout<<" $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$"<<endl;
cout<<" $ Joe Votto's Money Budgeting Program Version 2.0 $"<<endl;
cout<<" $ Created On October 23rd 2010 $"<<endl;
cout<<" $ Will Calculate Left Over Money After Bills Are Input $"<<endl;
cout<<" $ Then Save It To A File $"<<endl;
cout<<" $ USER MENU $"<<endl;
cout<<" $ Select Option 2 To Add To Report $"<<endl;
cout<<" $ Select Option 3 To Exit Program $"<<endl;
cout<<" $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$"<<endl;
cout<<endl;
cout<<" Please Select Menu Choice: ";
cin>>menuchoice;
if (menuchoice==1)
{
ifstream.savings ("C:/Users/primo/Documents/Dough/savings.txt", ios::in);
while (!savings.eof())
{
getline(savings,finaltotal);
cout<<finaltotal<<endl;
}
savings.close();
if (menuchoice==2)
{
savings.open ("C:/Users/primo/Documents/Dough/savings.txt", ios::app);
cout<<"Enter Date: ";
cin>>date;
savings<<"The Date Is: "<<date<<endl;
cout<<"Enter Bank Balance: ";
cin>>bal;
savings<<"Bank Balance: "<<bal<<endl;
cout<<"Enter Second Bank Balance: ";
cin>>secondbankbal;
savings<<"Second Bank Balance:"<<secondbankbal<<endl;
cout<<"Enter Expected Income Amount: ";
cin>>income;
savings<<"Income "<<income<<endl;
firsttally=income+secondbankbal+bal;
savings<<"Total Amount Of Income "<<firsttally<<endl;
cout<<"Income Total Is: "<<firsttally<<endl;
cout<<"Enter Rent Amount: ";
cin>>rent;
savings<<"Rent Is "<<rent<<endl;
sectally=firsttally-rent;
savings<<"Total To This Point Is "<<sectally<<endl;
cout<<"Total So Far Is: "<<sectally<<endl;
cout<<"Enter Cable, Internet, and Phone Amount: ";
cin>>net;
savings<<"Internet/Cable/Phone Amount Is "<<net<<endl;
thitally=sectally-net;
savings<<"Total To This Point is: "<<thitally<<endl;
cout<<"Total So Far Is: "<<thitally<<endl;
cout<<"Enter Cell Phone Amount: ";
cin>>cellphone;
savings<<"Cell Phone Amount:"<<cellphone<<endl;
frthtally=thitally-cellphone;
savings<<"Total At This Point Is "<<frthtally<<endl;
cout<<"Total So Far Is: "<<frthtally<<endl;
cout<<"Enter Gas Bill Amount ";
cin>>gas;
savings<<"Gas Amount is: "<<gas<<endl;
fifthtally=frthtally-gas;
savings<<"Total At This Point Is "<<fifthtally<<endl;
cout<<"Total So Far Is: "<<fifthtally<<endl;
cout<<"Enter Electric Bill Amount ";
cin>>ui;
savings<<"UI Amount Is: "<<ui<<endl;
sixthtally=fifthtally-ui;
savings<<"Total To This Point Is: "<<sixthtally<<endl;
cout<<"Total So Far Is: "<<sixthtally<<endl;
cout<<"Enter Credit Card Bill Amount: ";
cin>>creditcard;
savings<<"Credit Card Amount Is: "<<creditcard<<endl;
seventhtally=sixthtally-creditcard;
savings<<"Total To This Point Is: "<<seventhtally<<endl;
cout<<"Total So Far Is: "<<seventhtally<<endl;
cout<<"Enter Auto Insurance Amount: ";
cin>>insurance;
savings<<"Auto Insurance Amount Is: "<<insurance<<endl;
eigthtally=seventhtally-insurance;
savings<<"Total To This Point Is: "<<eigthtally<<endl;
cout<<"Final Total Is: "<<eigthtally<<endl;
billtotal=firsttally-eigthtally;
savings<<"Final Total Is: "<<billtotal<<endl;
leftovertally=firsttally-billtotal;
savings<<"Money Left Over Is: "<<leftovertally<<endl;
cout<<"Total Amount Deducted From Income Is: "<<billtotal<<endl;
savings<<"Total Amount Deducted Is: "<<billtotal<<endl;
cout<<"Thank You For Using My Money Budgeting Program, Created In C++ Language"<<endl;
savings<<endl;
savings<<endl;
savings<<endl;
savings.eof();
savings.close();
system ("PAUSE");
}
if (menuchoice==3)
system ("PAUSE");
return 0;
}
}