#include <fstream>
#include <iomanip>
#include <string>
using namespace std;
const double PI = 3.1416;
int main()
{
ifstream inFile;
string fname, lname;
int age, beginningBalance;
double length, width, radius, interestRate;
char ch1;
inFile.open("inData.txt");
inFile >> length >> width >> radius >> fname >> lname >> age >> beginningBalance >> interestRate >> ch1;
inFile.close();
ofstream outFile;
outFile.open("outData.txt");
outFile << "Rectangle: " << endl;
outFile << "Length = " << length << ", " << "width = " << width << ", " << "area = " << (length*width) << ", " << "parameter = "
<< (length*length) + (width*width) << endl;
outFile << "Circle: " << endl;
outFile << "Radius = " << radius << ", " << "area = " << PI*(radius*radius) << ", " << "circumference = " << radius*PI*2 << endl;
outFile << "Name: " << fname << " " << lname << ", " << "age: " << age << endl;
outFile << "beginning balance = $" << beginningBalance << ", " << "interest rate = " << interestRate << endl;
outFile << "balance at the end of the month = $" << beginningBalance - (interestRate/100)*beginningBalance << endl;
outFile << "the character that comes after " << ch1 << "in the ASCII set is B" << endl;
outFile.close();
return 0;
}
The file I'm inputting information from contains :
10.20 5.35
15.6
Randy Gill 31
18500 3.5
A
and when I run the program it returns as :
Rectangle:
Length = -9.25596e+061, width = -9.25596e+061, area = 8.56729e+123, parameter = 1.71346e+124
Circle:
Radius = -9.25596e+061, area = 2.6915e+124, circumference = -5.81571e+062
Name: , age: -858993460
beginning balance = $-858993460, interest rate = -9.25596e+061
balance at the end of the month = $-7.95081e+068
the character that comes after Ìin the ASCII set is B
I'm not really sure what's going wrong. I've checked everything I could for the last hour and there must be some semantic error that I'm blind to. Any help would be greatly appreciated! Thanks in advance.