hi ,
i'm writing a program which calculates registration fee of student and this program opens an external txt file.It's my first time writing a program with an input file so i'm kinda confused.my program asks for the status and number of credits but does not gimme the fee.
#include<iostream>
#include<fstream>
#include<iomanip>
#include<cstdlib>
#include<conio.h>
#include<cmath>
using namespace std;
int main()
{
string filename = "registration fee.txt";
ifstream inFile;
int n;
double fee;
char response1,response2;
char i,o,u,g;
inFile.open("registration fee.txt");
cout<<"please enter your status of residence,type i or o"<<endl;
cin>>response1;
cout<<"please enter your status of study,type u or g"<<endl;
cin>>response2;
cout<<"please enter your number of credits"<<endl;
cin>>n;
i = 0;
u = 0;
if ((response1 == i)&& (response2 == u))
{
if (n < 12)
{
fee = ((280 *n *0.35)+ (43 * n));
cout<<"status of residence : " << response1<<endl;
cout<<"status of study : "<<response2<<endl;
cout<<"number of credits : "<<endl;
cout<<fee<<endl;
if (n >= 12)
{
fee = ((280 *n *0.35)+ (43 * 12));
cout<<"status of residence : " << response1<<endl;
cout<<"status of study : "<<response2<<endl;
cout<<"number of credits : "<<endl;
}
}
}
g = 0;
if((response1 == i) && (response2 == g))
{
if (n < 9)
{
fee = (400 * n * 0.35) + (43 * n) + 10;
cout<<"status of residence : " << response1<<endl;
cout<<"status of study : "<<response2<<endl;
cout<<"number of credits : "<<endl;
cout<<fee<<endl;
if (n >= 9)
{
fee = (400 * n * 0.35) + (43 * 9) + 10;
cout<<"status of residence : " << response1<<endl;
cout<<"status of study : "<<response2<<endl;
cout<<"number of credits : "<<endl;
cout<<fee<<endl;
}
}
}
o = 1;
if ((response1 == o)&& (response2 == u))
{
if (n < 12)
{
fee = (280 * n) + (43 * n);
cout<<"status of residence : " << response1<<endl;
cout<<"status of study : "<<response2<<endl;
cout<<"number of credits : "<<endl;
cout<<fee<<endl;
if (n >= 12)
{
fee = (280 * n) + (43 * 12);
cout<<"status of residence : " << response1<<endl;
cout<<"status of study : "<<response2<<endl;
cout<<"number of credits : "<<endl;
cout<<fee<<endl;
}
}
}
if ((response1 == o) && (response2 == g))
{
if (n < 9)
{
fee = (400 * n * 0.35) + (43 * n) + 10;
cout<<"status of residence : " << response1<<endl;
cout<<"status of study : "<<response2<<endl;
cout<<"number of credits : "<<endl;
cout<<fee<<endl;
if (n >= 9)
{
fee = (400 * n * 0.35) + (43 * 9) + 10;
cout<<"status of residence : " << response1<<endl;
Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.
This thread is more than three months old
No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.