You are on page 1of 1

Q 1 (d)

#include <iostream>
#include <string>
#include <fstream>
#include <iomanip>
using namespace std;
int main ()
{
double length,width,area1,parameter,radius,area2;
double circum,balance,rate,finalb,age;
char ch;
string name1,name2;
ifstream infile;
ofstream outfile;
infile.open ("inData.txt");
outfile.open ("outData.txt");
infile >> length >> width ;
infile.ignore (200 ,'\n'); // not necessory : you may skip these lines of ignore
function
area1 = length *width;
parameter = 2*length+2*width;
infile >> radius;
infile.ignore (200 ,'\n');
area2= 3.1416 * (radius*2);
circum = 2*3.1416*radius;
infile >> name1 >>name2 >>age;
infile.ignore (200 ,'\n');
infile >> balance >>rate;
infile.ignore (200 ,'\n');
finalb =balance +(rate/1200*balance);
infile >> ch ;
infile.ignore (200 ,'\n');
outfile << fixed << showpoint << setprecision (2);
outfile << "Rectangle : " <<endl
<< " Length = "<< length << ", width = " << width
<< ", area = " << area1
<< ", parameter = " << parameter<<endl;
outfile << "Circle:"<<endl
<< "Radius = " << radius << ", area = " << area2
<< ", circumfarance = " << circum << endl;
outfile << "Name: " << name1<<" " << name2 << ", age : "<< age <<endl;
outfile << " Begining Balance = $"<< balance
<< ", interest rate= " << rate<<endl;
outfile << " Balance at the end of month = $"<< finalb<<endl;
outfile << "The character that comes after "<< ch
<< " in ASCII set is ";
ch = ch +1 ;
outfile << ch<< endl;
infile.close ();
outfile.close ();
return 0;

You might also like