1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285
|
#include <iostream>
#include <fstream>
#include <string>
#include <ctime>
using namespace std;
void main(int &minutes, int &minutesd,int &minutesn)
{
//functions declaring
void menu(int &minutes,int &minutesd,int &minutesn);
void help();
void login(int &minutes,int &minutesd,int &minutesn);
void bill(int &minutes,int &minutesd,int &minutesn);
void regular(int &minutes);
void blaster(int &minutesd, int &minutesn);
//function calling
login(minutes,minutesd,minutesn);
}
void login(int &minutes, int &minutesd,int &minutesn)
{
//menu function declaring
void menu(int &minutes, int &minutesd,int &minutesn);
//variable declare
string username,password;
string ps[2];
string un[2];
int x;
//collect login details
logins:
cout<<""<<endl;
cout<<"Enter Username : ";
cin>>username;
cout<<""<<endl;
cout<<"Enter Password : ";
cin>>password;
ifstream loginfile;
loginfile.open("login.txt");
for (x=0; x<2; x++)
{
loginfile>>un[x]>>ps[x]; //read login detailes from the file
loginfile.close();
//check login details
if(username==un[x] && password==ps[x])
{
menu(minutes,minutesd,minutesn);
}
else
{
cout<<""<<endl;
cout << "Invalid login details" << endl;
cout << "" << endl;
goto logins; //return to get login details
}
}
}
void menu(int &minutes, int &minutesd,int &minutesn)
{
//functions declaring
void help();
void bill(int &minutes, int &minutesd,int &minutesn);
themenu:
int sel;
cout<<"\t \t \t \t ..::: Menu :::.."<<endl;
cout<<""<<endl;
cout<<"\t \t \t ==============================="<<endl;
cout<<""<<endl;
cout<<""<<endl;
cout<<"\t \t \t \t 1.Help "<<endl;
cout<<""<<endl;
cout<<"\t \t \t \t 2.Generate Bill "<<endl;
cout<<""<<endl;
cout<<"\t \t \t \t 3.Exit "<<endl;
cout<<""<<endl;
cout<<""<<endl;
cout<<"\t \t \t ==============================="<<endl;
cout<<""<<endl;
cout<<"\t \t \t Enter your Selection : ";
cin>>sel;
switch(sel)
{
case 1: help();
break;
case 2: bill(minutes,minutesd,minutesn);
break;
case 3: system("exit");
break;
default:
cout<<"Invalid Selection"<<endl;
cout<<""<<endl;
cout<<"Please Renter Your Selection"<<endl;
goto themenu;
break;
}
}
void help()
{
cout<<"\t \t \t======================"<<endl;
cout<<"\t \t \t System Guildelines"<<endl;
cout<<"\t \t \t======================"<<endl;
cout<<""<<endl;
cout<<"When you enter the package type in the invoice you have to enter the package type as follows "<<endl;
cout<<""<<endl;
cout<<"\t \t Regular Package- 'r' or 'R' "<<endl;
cout<<"\t \t Blaster Package- 'b' or 'B' "<<endl;
cout<<""<<endl;
cout<<"If you are using regular package use should enter minutes that you have used. If you are using blaster package you have to enter minutes that you have used in day time and night time seperatly"<<endl;
cout<<""<<endl;
cout<<"Time ranges are as follows,"<<endl;
cout<<""<<endl;
cout<<"\t \tDay Time : 6.00 am to 6.00 pm"<<endl;
cout<<"\t \tNight Time : 6.00 am to 6.00 pm"<<endl;
}
void bill(int &minutes, int &minutesd,int &minutesn)
{
//external function declare
void regular(int &minutes);
void blaster(int &minutesd, int &minutesn);
//variables declaring
int accno,totalamount,amount,blamind,blaminn;
char servicecode;
string servicetype;
//collect details
ag:
cout<<""<<endl;
cout<<"Please Enter Your Account Number"<<endl;
cin>>accno;
service:
cout<<"Please Enter Your Service Code"<<endl;
cin>>servicecode;
//check the package type
if (servicecode =='r' | servicecode =='R' )
{
regular(minutes); //call regular package fucntion
servicetype="Regular Package";
int rm=minutes;
if (rm>50)
{
amount=(rm-50)*0.75;
totalamount=100+amount;
}
else
{
amount=0;
}
}
else if (servicecode =='b' | servicecode =='B')
{
blaster(minutesd,minutesn); //call blaster package fucntion
servicetype="Blaster Package";
int md=minutesd;
int mn=minutesn;
if (md>75)
{
blamind=(md-75)*0.50;
}
else
{
blamind=0;
}
if (mn>100)
{
blaminn=(mn-100)*0.25;
}
else
{
blaminn=0;
}
totalamount=250+blamind+blaminn;
}
else
{
cout<<"Service Code is Wrong"<<endl;
goto service; //return to get service type
}
//generate the bill
time_t tme;
time (&tme);
cout<<""<<endl;
cout<<"\t \t ===================================="<<endl;
cout<<" \t \t \t \t Invoice "<<endl;
cout<<"\t \t ===================================="<<endl;
cout<<""<<endl;
cout<<""<<endl;
//cout<<"\t \t \tDate & Time : "<<ctime(&tme)<<endl;
cout<<""<<endl;
cout<<"\t \t Account No : "<<accno<<endl;
cout<<""<<endl;
cout<<"\t \t Service Type : "<<servicetype<<endl;
cout<<""<<endl;
if (servicetype =="Regular Package")
{
cout<<"\t \t Used Minutes Amount : "<<minutes<<endl;
cout<<""<<endl;
//export to data file
ofstream detailsfile;
detailsfile.open("regular.txt");
detailsfile<<"\n"<<endl;
detailsfile<<accno<<"\t";
detailsfile<<minutes<<"\t";
detailsfile<<totalamount;
detailsfile<<"\n"<<endl;
detailsfile.close();
}
else
{
cout<<"\t \t Used Minutes of Day Time : "<<minutesd<<endl;
cout<<""<<endl;
cout<<"\t \t Used Minutes of Night Time : "<<minutesn<<endl;
cout<<""<<endl;
//export to data file
ofstream detailsfile;
detailsfile.open("blaster.txt");
detailsfile<<"\n"<<endl;
detailsfile<<accno<<"\t";
detailsfile<<minutesd<<"\t";
detailsfile<<minutesn<<"\t";
detailsfile<<totalamount;
detailsfile<<"\n"<<endl;
detailsfile.close();
}
cout<<"\t \t Total Charges : "<<totalamount<<endl;
}
void regular(int &minutes)
{
cout<<"Please Enter the Used Number of the Minutes "<<endl;
cin>>minutes;
}
void blaster(int &minutesd, int &minutesn)
{
cout<<"Please Enter the Used Number of the Minutes in Day Time "<<endl;
cin>>minutesd;
cout<<"Please Enter the Used Number of the Minutes in Night Time "<<endl;
cin>>minutesn;
}
|