Just started learning c++ today and im pretty boggled. its an amazing language but im having some trouble overwriting a file
#include <iostream>
#include <fstream>
using namespace std;
int main( )
{
double payIncrease = 7.6;
double annual;
double annualIncrease;
double newAnnual;
double monthlyIncrease;
double newMonthly;
ifstream inStream;
ofstream outStream;
// heres where the problem lies
inStream.open("annualSalary.txt" );
outStream.open("newAnnualSalary.txt");
if i change newAnnualSalary.txt to annualSalary.txt i get some very weird numbers. does anyone know why?
inStream >> annual;
inStream.close();
double monthly = (annual/12);
annualIncrease = ((annual/100)*payIncrease);
monthlyIncrease = ((monthly/100)*payIncrease);
newMonthly = (monthly + monthlyIncrease);
newAnnual = (annual + annualIncrease);
outStream <<"annual salary was: "<< annual << "\n" ;
outStream <<"new annual salary is " << newAnnual << "\n ";
outStream <<"new monthly salary is " << newMonthly <<"\n ";
outStream.close();
return 0;
}
im aware this is a very low skill level question but i am just learning.