program execute but output negative answer

#include <iostream>
#include <fstream>
#include <iomanip>

using namespace std;

int main ()
{

ifstream inFile;
ofstream outFile;

int sa, tk, sa1, tk1, sa2, tk2, sa3, tk3;

double totalTicket;
double totalSales;

inFile.open ("stadttik");
outFile.open ("stadtot");

outFile << fixed << showpoint;
outFile << setprecision(2);

cout << " File in process..." <<endl;

inFile >> tk >> tk1 >> tk2 >> tk3;

totalTicket = tk + tk1 + tk2 + tk3;
outFile << "Total ticket sold at the game = " << totalTicket <<endl <<endl;

inFile >> sa >> sa1 >> sa2 >> sa3;

totalSales = sa + sa1 + sa2 + sa3;
outFile << "Total sales amount = $" << totalSales <<endl;

inFile.close();
outFile.close();

return 0;

}
Please edit your post and make sure your code is [code]between code tags[/code] so that it has line numbers and syntax highlighting, as well as proper indentation.

We have no way to know how your code behaves unless you give us examples of the file it reads from.
Topic archived. No new replies allowed.