#include<iostream.h>
#include<stdlib.h>
#include<time.h>
#include<stdio.h>
#include<conio.h>
#include<windows.h>

class TelCom
{
public:
	void menu();
	void billing();
	void viewlogs();
	void prepaidOperations(int form);
	double compute(char user[9],int cid,char plan,double csms,int cmms,double ccall);
};
class BoxLines
{
public:
	void box(int x1,int y1,int x2,int y2);
	void line(int x1, int y1, int x2);
};
void sleep(unsigned int mseconds)
{
    clock_t goal = mseconds + clock();
    while (goal>clock());
}
void gotoxy(int x,int y)
{
	HANDLE hConsoleOutput;
	COORD dwCursorPosition;
	cout.flush();
	dwCursorPosition.X = x;
	dwCursorPosition.Y = y;
	hConsoleOutput = GetStdHandle(STD_OUTPUT_HANDLE);
	SetConsoleCursorPosition(hConsoleOutput,dwCursorPosition);
}
void main(void)
{ 
	TelCom j;
	BoxLines b;
	char pass[5], user[6];
	system("cls");
	system("color b");
	gotoxy(28,7);printf("4J's TeleCommunication");
	b.box(5,5,70,23);
	b.line(5,18,70);
	gotoxy(34,18);printf(" LOADING ");
	b.line(5,9,70);
	for(int h=1; h<=3; h++)
	{
		if(h==1) { gotoxy(30,21); printf("Checking Files..."); }
		if(h==2) { gotoxy(30,21); printf("Checking Folders..."); }
		if(h==3) { gotoxy(30,21); printf("Loading System..."); }
		for(int k=8; k<68; k++)
		{
			gotoxy(k,20); printf("º");
		}
		for(k=8; k<68; k++)
		{
			gotoxy(k,20); putch(219);
			sleep(20);
		}
}
	system("cls");
	system("color b");
	do
	{
		gotoxy(32,7); printf("4J's TeleCommunication");
		b.box(20,5,65,23);
		b.line(20,9,65);
		b.box(30,13,55,16);
		gotoxy(32,14); printf("Username: ________");
		gotoxy(32,15); printf("Password: ______");
		b.line(20,19,65);
		gotoxy(36,19); printf(" Notification ");
		gotoxy(42,14); gets(user);
		gotoxy(42,15); gets(pass);
		gotoxy(42,15); printf("******");
		if(strcmp(user,"jhommark")!=0 && strcmp(pass,"jhom14")!=0)
		{
			gotoxy(22,21); printf("The username and password did not match!!!");
			getch();
		}
	} while(strcmp(user,"jhommark")!=0 && strcmp(pass,"jhom14")!=0);
	gotoxy(35,20); printf("Loading to Menu...");
	for(int k=22;k<64;k++)
	{
		gotoxy(k,21); printf("º");
	}
	for(k=22;k<64;k++)
	{
		gotoxy(k,21); putch(219);
		sleep(20);
	}
	j.menu();
}
void TelCom::menu()
{
	TelCom j;
	BoxLines b;
	char choice,select,menu='m',lmenu='m';
	system("color b");
	while(1)
	{
	switch(menu)
	{
	case 'm':
	case 'M':
		system("cls");
		system("color b");
		b.box(20,3,60,5);
		b.box(20,6,60,20);
		gotoxy(30,4); printf("4J's TeleCommunication");
		gotoxy(35,6); printf(" MAIN MENU ");
		gotoxy(22,8); printf("[A] Postpaid Billing");
		gotoxy(22,10); printf("[B] Prepaid Operations");
		gotoxy(22,12); printf("[C] Admin");
		gotoxy(22,14); printf("[D] Exit");
		b.line(20,16,60);
		gotoxy(22,18); printf("Choose an option(A, B, C, D): ");
		cin>>choice;
		switch(choice)
		{
		case 'a':
		case 'A':
			system("cls");
			j.billing();
			cout<<"\n\n                           Press M to go back to menu: ";
			cin>>menu;
			break;
		case 'b':
		case 'B':
			while(1)
			{
			switch(lmenu)
			{
			case 'm':
			case 'M':
				system("cls");
				system("color b");
				b.box(20,3,60,5);
				b.box(20,6,60,20);
				gotoxy(30,4); printf("4J's TeleCommunication");
				gotoxy(31,6); printf(" Prepaid Operations ");
				gotoxy(22,8); printf("[A] Paload");
				gotoxy(22,10); printf("[B] Share A Load");
				gotoxy(22,12); printf("[C] Send Message");
				gotoxy(22,14); printf("[D] Check Balance");
				b.line(20,16,60);
				gotoxy(22,18); printf("Choose an option(A, B, C, D): ");
				cin>>select;
				switch(select)
				{
				case 'a':
				case 'A':
					system("cls");
					j.prepaidOperations(1);
					cout<<"\n\n                   Press M to go back to Prepaid Operations: ";
					cin>>lmenu;
					break;
				case 'b':
				case 'B':
					system("cls");
					j.prepaidOperations(2);
					cout<<"\n\n                   Press M to go back to Prepaid Operations: ";
					cin>>lmenu;
					break;
				case 'c':
				case 'C':
					system("cls");
					j.prepaidOperations(3);
					cout<<"\n\n                   Press M to go back to Prepaid Operations: ";
					cin>>lmenu;
					break;
				case 'd':
				case 'D':
					system("cls");
					j.prepaidOperations(4);
					cout<<"\n\n                   Press M to go back to Prepaid Operations: ";
					cin>>lmenu;
					break;
				case 'e':
				case 'E':
					system("cls");
					cout<<"                           Goodbye!!!\n\n";
					exit(0);
					break;
				default:
					system("cls");
					cout<<"                           Incorrect Choice!!!\n\n";
					cout<<"\n\n                   Press M to go back to Prepaid Operations: ";
					cin>>lmenu;
					break;
				}
			}
			}
			break;
		case 'c':
		case 'C':
			system("cls");
			cout<<"                           Nothing To Display!!!\n\n";
			cout<<"\n\n                           Press M to go back to menu: ";
			cin>>menu;
			break;
		case 'd':
		case 'D':
			system("cls");
			cout<<"                           Goodbye!!!\n\n";
			exit(0);
			break;
		default:
			system("cls");
			cout<<"                           Incorrect Choice!!!\n\n";
			cout<<"\n\n                           Press M to go back to menu: ";
			cin>>menu;
			break;
		}
	}
	}
}
void TelCom::billing()
{
	TelCom j;
	char view,plan,user[9];
	int cid=0,cmms=0;
	double csms=0,ccall=0;
	char dateStr[9],timeStr[9];
	system("color b");
 	_strdate(dateStr);
    cout<<"                                                     Transaction Date: "<<dateStr;
    _strtime(timeStr);
    cout<<"\n                                                     Transaction Time: "<<timeStr;
	cout<<"\n\n\t\t     ######################################"<<endl;
    cout<<"\t\t     #       4J's TeleCommunication       #"<<endl;
    cout<<"\t\t     ######################################"<<endl;
	cout<<"\n\n\t\t\t\t\t\t        Additional Charges Php		";
	cout<<"\n\n       Flat Rate	 Free SMS   Free Call (mins)   SMS	 MMS  Call (min)";
	cout<<"\nPlan    ";
	cout<<"\nA      php  500             500           20            1         15        7";
	cout<<"\nB      php  800             600           40            1         15      6.5";
	cout<<"\nC      php 1200             650           60          0.8         15        6";
	cout<<"\nD      php 1500 	    700	          80	      0.8	  15	  5.5";
	cout<<"\nE      php 1800 	    750	         100	      0.6	  15	    5";
	cout<<"\nF      php 2000 	    800	         120	      0.6	  15	  4.5"; 
	cout<<"\n\nTransaction Processed by: ";
	cin>>user;
	cout<<"Input Client Acct. No.: ";
	cin>>cid;
	cout<<"Input Plan: ";
	cin>>plan;
	cout<<"SMS: ";
	cin>>csms;
	cout<<"MMS: ";
	cin>>cmms;
	cout<<"Calls: ";
	cin>>ccall;
	cout<<"\nPlease pay this amount: Php "<<j.compute(user,cid,plan,csms,cmms,ccall);
	cout<<"\n\n[A] View Billing Statement\n";
	cout<<"[B] View Logs\n";
	cout<<"[C] Print Billing Statement\n\n";
	cout<<"Choose from A, B, C: ";
	cin>>view;
		switch(view)
		{
		case 'a':
		case 'A':
			system("cls");
			j.viewlogs();
			break;
		case 'b':
		case 'B':
			system("cls");
			j.viewlogs();
			break;
		case 'c':
		case 'C':
			system("cls");
			FILE *fp;
			fp = fopen("logs.txt","a");
			fprintf(fp,"Transaction Date: %s\nTransaction Time: %s\nTransaction Processed by: %s\nClient Acct. No.: %d\nPlan: %c\nSMS: %g\nMMS: %d\nCalls: %g\n\n",dateStr,timeStr,user,cid,plan,csms,cmms,ccall);
			cout<<"Billing Statement has been printed!!!\n\n";
			fclose(fp);
			break;
		default:
			system("cls");
			cout<<"                           Incorrect Choice!!!\n\n";
			break;
		}
}
double TelCom::compute(char user[9],int cid,char plan,double csms,int cmms,double ccall)
{
	int fr=0,fsms=0,fcall=0,mms=0;
	double sms=0,call=0,total=0;
	if(plan=='a' || plan=='A')
	{
		fr = 500;
		fsms = 500;
		fcall = 20;
		sms = 1;
		mms = 15;
		call = 7;
	}else if(plan=='b')
	{
		fr = 800;
		fsms = 600;
		fcall = 40;
		sms = 1;
		mms = 15;
		call = 6.5;
	}else if(plan=='c')
	{
		fr = 1200;
		fsms = 650;
		fcall = 60;
		sms = 0.8;
		mms = 15;
		call = 6;
	}else if(plan=='d')
	{
		fr = 1500;
		fsms = 700;
		fcall = 80;
		sms = 0.8;
		mms = 15;
		call = 5.5;
	}else if(plan=='e')
	{
		fr = 1800;
		fsms = 750;
		fcall = 100;
		sms = 0.6;
		mms = 15;
		call = 5;
	}else if(plan=='f')
	{
		fr = 2000;
		fsms = 800;
		fcall = 120;
		sms = 0.6;
		mms = 15;
		call = 4.5;
	}
	if(csms<=fsms) csms = fr;
	else if(csms>fsms)
	{
		csms -= fsms;
		csms += fr;
	}
	cmms *= mms;
	if(ccall>fcall)
	{
		ccall -= fcall;
		ccall *= call;
	}
	total = csms + cmms + ccall;
	return total;
}
void TelCom::viewlogs()
{
	FILE *fp;
	int c;
	fp = fopen("logs.txt","r");
	c = fgetc(fp) ;
	while(c!=EOF)
	{
		putch(c);
		c = fgetc(fp);
	}
   fclose(fp);
}
void TelCom::prepaidOperations(int form)
{
	FILE *fp1,*fp2,*fp3;
	fp1 = fopen("loadlogs.txt","a");
	fp2 = fopen("userload.txt","r");
	int amt=0,nbal=0,bal=0;
	char dateStr[9],timeStr[9];
 	_strdate(dateStr);
	_strtime(timeStr);
	fscanf(fp2,"%d",&bal);
	cout<<"                                                     Transaction Date: "<<dateStr;
	cout<<"\n                                                     Transaction Time: "<<timeStr<<"\n\n";
	switch(form)
	{
	case 1:
		cout<<"Balance: "<<bal<<"\n";
		cout<<"\nInput Load amount: Php ";
		cin>>amt;
		if(amt<50)
		{
			printf("\nMinimum load is Php 50.00!!!");
			fclose(fp2);
		}else{
		fprintf(fp1,"4J's TelCom loaded Php %g to 09170001111 on %s - %s\n\n",amt,dateStr,timeStr);
		fscanf(fp2,"%d",&bal);
		nbal = bal + amt;
		fclose(fp2);
		fp3 = fopen("userload.txt","w");
		cout<<"\nNew Balance: "<<nbal;
		fprintf(fp3,"%d",nbal);
		cout<<"\n\nYou have sucessfully loaded Php "<<amt<<" to 09170001111!!!";
		}
		fclose(fp1);
		fclose(fp3);
		break;
	case 2:
		cout<<"Balance: "<<bal<<"\n";
		cout<<"\nShare A Load amount: Php ";
		cin>>amt;
		if(amt<50) //having an error here if amt is below 50
		{
			printf("\nMinimum amount to share is Php 50.00!!!");
			fclose(fp2);
		}else{
		fprintf(fp1,"09170001111 shared a load of %g to 09171111000 on %s - %s\n\n",amt,dateStr,timeStr);
		if(bal<amt) cout<<"\nInsufficient balance!!!"; //having an error here if amt is below balance
		else{
		nbal = bal - amt;
		fclose(fp2);
		fp3 = fopen("userload.txt","w");
		cout<<"\nNew Balance: "<<nbal;
		fprintf(fp3,"%d",nbal);
		cout<<"\n\nYou have sucessfully shared Php "<<amt<<" to 09170001111!!!";
		}
		}
		fclose(fp1);
		fclose(fp3);
		break;
	case 3:
		if(bal<1) printf("\nCheck Operator Services!!!");
		else{
		nbal = bal - 1;
		fclose(fp2);
		fp3 = fopen("userload.txt","w");
		cout<<"\nNew Balance: "<<nbal;
		fprintf(fp3,"%d",nbal);
		cout<<"\n\nMessage Sent!!!";
		}
		fclose(fp1);
		fclose(fp3);
		break;
	case 4:
		cout<<"\nYour balance is Php "<<bal<<"!!!";
		fclose(fp2);
		fclose(fp1);
		break;
	default:
		cout<<"\nNothing to display!!!\n\n";
		fclose(fp1);
		fclose(fp2);
		break;
	}
}
void BoxLines::box(int x1,int y1,int x2,int y2)
{
	int x;
	gotoxy(x1,y1); putch(201); gotoxy(x2,y1); putch(187);
	gotoxy(x1,y2); putch(200); gotoxy(x2,y2); putch(188);
	for(x=x1+1;x<x2;x++) { gotoxy(x,y1); putch(205); gotoxy(x,y2); putch(205); }
	for(x=y1+1;x<y2;x++) { gotoxy(x1,x); putch(186); gotoxy(x2,x); putch(186); }
}
void BoxLines::line(int x1,int y1,int x2)
{
	int k;
	gotoxy(x1,y1); putch(204); gotoxy(x2,y1); putch(185);
	for(k=x1+1;k<x2;k++) { gotoxy(k,y1); putch(205); }
}
thelamb commented: 400+ lines of code without stating what the error is, kidding me? +0

Recommended Answers

All 3 Replies

Please try to simplify your problem down to a < 20 line piece of code. Then also explain the problem in much more detail. You'll find that it is highly likely that no one will help you in the current form that you have posed your question.

Dave

here it is..i converted to a small one..i'm having an error in if else condition..when u load or share a load below 50, i got error reporting..but when it's above, it's ok!!!please help me in this prob..maybe it's in the if else statement or somewhere..thank you all in advance..hope someone will reply..

#include<iostream.h>
#include<stdlib.h>
#include<time.h>
#include<stdio.h>
#include<conio.h>
#include<windows.h>

void gotoxy(int x,int y)
{
	HANDLE hConsoleOutput;
	COORD dwCursorPosition;
	cout.flush();
	dwCursorPosition.X = x;
	dwCursorPosition.Y = y;
	hConsoleOutput = GetStdHandle(STD_OUTPUT_HANDLE);
	SetConsoleCursorPosition(hConsoleOutput,dwCursorPosition);
}
void load(int form)
{
	FILE *fp1,*fp2,*fp3;
	fp1 = fopen("prepaidlogs.txt","a");
	fp2 = fopen("userload.txt","r");
	float amt,nbal,bal;
	char dateStr[9],timeStr[9];
 	_strdate(dateStr);
	_strtime(timeStr);
	fscanf(fp2,"%f",&bal);
	cout<<"                                                     Transaction Date: "<<dateStr;
	cout<<"\n                                                     Transaction Time: "<<timeStr<<"\n\n";
	switch(form)
	{
	case 1:
		cout<<"\nInput Load amount: Php ";
		cin>>amt;
		if(amt<50)
		{
			cout<<"\nMinimum load is Php 50.00!!!";
			fclose(fp2);
		}else{
		fprintf(fp1,"4J's TelCom loaded Php %.2f to 09170001111 on %s - %s\n\n",amt,dateStr,timeStr);
		nbal = bal + amt;
		fclose(fp2);
		fp3 = fopen("userload.txt","w");
		fprintf(fp3,"%.2f",nbal);
		printf("\nYou have sucessfully loaded Php %.2f to 09170001111!!!",amt);
		}
		fclose(fp1);
		fclose(fp3);
		break;
	case 2:
		cout<<"\nShare A Load amount: Php ";
		cin>>amt;
		if(amt<50)
		{
			cout<<"\nMinimum amount to share is Php 50.00!!!";
			fclose(fp2);
		}else{
		fprintf(fp1,"09170001111 shared a load of Php %.2f to 09171111000 on %s - %s\n\n",amt,dateStr,timeStr);
		if(bal<amt) cout<<"\nInsufficient balance!!!";
		else{
		nbal = bal - amt;
		fclose(fp2);
		fp3 = fopen("userload.txt","w");
		fprintf(fp3,"%.2f",nbal);
		printf("\nYou have sucessfully shared Php %.2f to 09170001111!!!",amt);
		}
		}
		fclose(fp1);
		fclose(fp3);
		break;
	case 3:
		if(bal<1) cout<<"Check Operator Services!!!";
		else{
		nbal = bal - 1;
		fclose(fp2);
		fp3 = fopen("userload.txt","w");
		fprintf(fp3,"%.2f",nbal);
		cout<<"Message Sent!!!";
		}
		fclose(fp1);
		fclose(fp3);
		break;
	case 4:
		printf("\n\nYour balance is Php %.2f",bal);
		fclose(fp1);
		fclose(fp2);
		break;
	default:
		cout<<"Nothing to display!!!";
		fclose(fp1);
		fclose(fp2);
		break;
	}
}
void main(void)
{
	int select;
				system("cls");
				system("color b");
				gotoxy(30,4); printf("4J's TeleCommunication");
				gotoxy(31,6); printf(" Prepaid Operations ");
				gotoxy(22,8); printf("[1] Paload");
				gotoxy(22,10); printf("[2] Share A Load");
				gotoxy(22,12); printf("[3] Send Message");
				gotoxy(22,14); printf("[4] Check Balance");
				gotoxy(22,18); printf("Choose an option(1, 2, 3, 4): ");
				cin>>select;
				system("cls");
				system("color b");
				load(select);
}

or is it just the compiler who's having an error?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.