C++ PROGRAMS (STAGE-VI)



C++ PROGRAMS
 


// EMPLOYEE DATABASE USING ARRAYS

#include<iostream.h>
#include<conio.h>
#include<string.h>
void main()
{
int eno[25],count,emp,swap=1; char grade[25];
char name[25][25],tempn[25][25]; long float comm[25],temp;
clrscr();
cout<<"ENTER THE NUMBER OF EMPLOYEES FOR DATABASE : ";
cin>>emp;
for(count=0;count<emp;count++)
{
cout<<"\n\nENTER EMPLOYEE NAME : ";
cin>>name[count];
cout<<"\nENTER EMPLOYEE NUMBER : ";
cin>>eno[count];
cout<<"\nENTER EMPLOYEE COMMISSION : ";
cin>> comm[count];
if(comm[count]>60000)
grade[count]='A';
else if(comm[count]>40000)
grade[count]='B';
else if(comm[count]>20000)
grade[count]='C';
else
grade[count]='D';
}
clrscr();
do
{
swap=0;
for(count=0;count<(emp-1);count++)
{
if(eno[count]>eno[count+1])
{
temp=eno[count];
eno[count]=eno[count+1];
eno[count+1]=temp;
strcpy(tempn[count],name[count]);
strcpy(name[count],name[count+1]);
strcpy(name[count+1],tempn[count]);
temp=comm[count];
comm[count]=comm[count+1];
comm[count+1]=temp;
swap=1;
temp=grade[count];
grade[count]=grade[count+1];
grade[count+1]=temp;
}
}
}while(swap==1);
cout<< "EMPLOYEE DETAILS: "<<endl<<endl;
cout<< "\nNAME\t\tNUMBER\t\tGRADE\t\tCOMMISSION"<<endl<<endl;
for(count=0;count<emp;count++)
{
cout<<name[count]<<"\t\t"<<eno[count]<<"\t\t";
cout<<grade[count]<<"\t\t"<<comm[count]<<endl<<endl;
}
getch();
}



/*OUTPUT
ENTER THE NUMBER OF EMPLOYEES FOR DATABASE : 5
ENTER EMPLOYEE NAME : RAM
ENTER EMPLOYEE NUMBER : 7
ENTER EMPLOYEE COMMISSION : 636363
ENTER EMPLOYEE NAME : PRASAD
ENTER EMPLOYEE NUMBER : 10
ENTER EMPLOYEE COMMISSION : 45983
ENTER EMPLOYEE NAME : VINAY
ENTER EMPLOYEE NUMBER : 35
ENTER EMPLOYEE COMMISSION : 37945
ENTER EMPLOYEE NAME : JAY
ENTER EMPLOYEE NUMBER : 3
ENTER EMPLOYEE COMMISSION : 27000
ENTER EMPLOYEE NAME : BARNIK
ENTER EMPLOYEE NUMBER : 12
ENTER EMPLOYEE COMMISSION : 19875
EMPLOYEE DETAILS:
NAME NUMBER GRADE COMMISSION
JAY 3 C 27000
RAM 7 A 636363
PRASAD 10 B 45983
BARNIK 12 D 19875
VINAY 35 C 37945
*/



_____________http://sundcs.blogspot.com/____________




//A HOTEL FOOD BILLING PROGRAM.

#include<iostream.h>
#include<conio.h>
#include<string.h>
//VARIABLES USED
int choice, bill=0, r1, r2, r3, count=0, prod=0;
char rachit[50]; char items[50][50];
//FUNCTIONS DECLARATIONS
void copyright();
void border();
void entry();
void hello();
void menu();
void bil(int);
//MAIN PROGRAM
void main()
{
entry();
do
{
menu();
gotoxy(7,43);
cout<<"ENTER YOUR CHOICE : ";
cin>>choice;
while(choice<0||choice>31)
{
gotoxy(7,45);
cout<<"INVALID ENTRY. PLEASE RE-ENTER YOUR CHOICE : ";
cin>>choice;
}
switch(choice)
{
case 1:bill+=25; hello(); break;
case 2:bill+=45; hello(); break;
case 3:bill+=30; hello(); break;
case 4:bill+=35; hello(); break;
case 5:bill+=40; hello(); break;
case 6:bill+=45; hello(); break;
case 7:bill+=25; hello(); break;
case 8:bill+=35; hello(); break;
case 9:bill+=40; hello(); break;
case 10:bill+=10; hello(); break;
case 11:bill+=45; hello(); break;
case 12:bill+=45; hello(); break;
case 13:bill+=10; hello(); break;
case 14:bill+=20; hello(); break;
case 15:bill+=25; hello(); break;
case 16:bill+=15; hello(); break;
case 17:bill+=20; hello(); break;
case 18:bill+=20; hello(); break;
case 19:bill+=20; hello(); break;
case 20:bill+=25; hello(); break;
case 21:bill+=40; hello(); break;
case 22:bill+=20; hello(); break;
case 23:bill+=35; hello(); break;
case 24:bill+=40; hello(); break;
case 25:bill+=35; hello(); break;
case 26:bill+=35; hello(); break;
case 27:bill+=15; hello(); break;
case 28:bill+=40; hello(); break;
case 29:bill+=45; hello(); break;
case 30:bill+=45; hello(); break;
default: bill+=0;
}
prod++;
}while(choice>0 && choice<31);
bil(prod);
copyright();
}
void border()
{
for(r3=3; r3<=79; r3++)
{
gotoxy(r3,1);
cout<<"*";
gotoxy(r3,50);
cout<<"*";
}
for(r1=0, r2=1; r1<50; r1++, r2++)
{
gotoxy(3,r2);
cout<<"*";
gotoxy(79,r2);
cout<<"*";
}
}
void copyright()
{
getch();
clrscr();
border();
gotoxy(22,18);
cout << "PROGRAM EXCLUSIVELY CREATED BY :";
gotoxy(30,20);
cout << "RACHIT AGRAWAL";
gotoxy(20,22);
cout << "EMAIL: rachit_agrawal9@gmail.com";
gotoxy(15,24);
cout << "PROGRAM TO BE DISTRIBUTED FREELY AS SHAREWARE.";
gotoxy(25,26);
cout << "PROGRAM CODE NOT TO BE MODIFIED.";
gotoxy(10,28);
cout << "MODIFICATIONS WITHOUT HIS PRIOR PERMISSION INVITE LEGAL ACT.";
gotoxy(15,30);
cout << "SUGGESTIONS AND COMMENTS WILL BE APRRECIATED AT
rachit_agrawal9@rediffmail.com";
gotoxy(25,32);
cout << "THANK YOU "<<rachit<<" FOR USING THE PROGRAM. ";
gotoxy(27,34);
cout << "HAVE A PROGRESSIVE DAY! ";
getch();
}
void entry()
{
clrscr();
cout<<"\nWELCOME!!!WELCOME!!!\n\nTO THE MOST PRESTIGIOUS RESTAURANT.\
\n'THE AFFORDABLES''!!!";
for(r3=7; r3<=73; r3++)
{
gotoxy(r3,16);
cout<<"*";
gotoxy(r3,22);
cout<<"*";
}
for(r1=0, r2=17; r1<=4; r1++, r2++)
{
gotoxy(7,r2);
cout<<"*";
gotoxy(73,r2);
cout<<"*";
}
gotoxy(9,19);
cout << "PLEASE ENTER YOUR NAME : ";
cin.getline ( rachit, 24);
}
void hello()
{
switch(choice)
{
case 1: strcpy(items[count],"BHEL PURI\t\t25");break;
case 2: strcpy(items[count],"BHAJI PAV\t\t45");break;
case 3: strcpy(items[count],"CASSATA\t\t30");break;
case 4: strcpy(items[count],"COLD COFFEE\t\t35");break;
case 5: strcpy(items[count],"CHOCO DRIP SHAKE\t40");break;
case 6: strcpy(items[count],"CHIKOO SHAKE\t\t45");break;
case 7: strcpy(items[count],"DOUGHNUTS\t\t25");break;
case 8: strcpy(items[count],"DELHI CHAT\t\t35");break;
case 9: strcpy(items[count],"FALUDA KULFI\t\t40");break;
case 10:strcpy(items[count],"GULAB JAMUN\t10");break;
case 11:strcpy(items[count],"HAKKA NOODLES\t45");break;
case 12:strcpy(items[count],"HAM BURGER\t\t45");break;
case 13:strcpy(items[count],"IMARTI\t\t10");break;
case 14:strcpy(items[count],"INDIAN SHARBAT\t20");break;
case 15:strcpy(items[count],"JAPANESE JEMS\t25");break;
case 16:strcpy(items[count],"KACHORI\t\t15");break;
case 17:strcpy(items[count],"KINLEYS SODA\t20");break;
case 18:strcpy(items[count],"MASALA PARATHA\t20");break;
case 19:strcpy(items[count],"MASALA PAPAD\t20");break;
case 20:strcpy(items[count],"MANGO SHAKE\t25");break;
case 21:strcpy(items[count],"NAVRATNA KORMA\t40");break;
case 22:strcpy(items[count],"PANI PURI\t\t20");break;
case 23:strcpy(items[count],"PASTA\t\t35");break;
case 24:strcpy(items[count],"PIZZA\t\t40");break;
case 25:strcpy(items[count],"RASMALAI\t\t35");break;
case 26:strcpy(items[count],"RAJBHOG ICE-CREAM\t35");break;
case 27:strcpy(items[count],"SAMOSA\t\t15");break;
case 28:strcpy(items[count],"SWEET CORN SOUP\t40");break;
case 29:strcpy(items[count],"SPEGGATI\t\t45");break;
case 30:strcpy(items[count],"TOMATO SOUP\t45");break;
}
count++;
}
void menu()
{
clrscr(); border();
gotoxy(7,4);
cout << "WELCOME " << rachit;
gotoxy(7,6);
cout<<"DELICACIES\tPRICE";
gotoxy(7,8);
cout<<"1 BHEL PURI\t\t25";
gotoxy(7,9);
cout<<"2 BHAJI PAV\t\t45";
gotoxy(7,10);
cout<<"3 CASSATA\t\t30";
gotoxy(7,11);
cout<<"4 COLD COFFEE\t\t35";
gotoxy(7,12);
cout<<"5 CHOCO DRIP SHAKE\t40";
gotoxy(7,13);
cout<<"6 CHIKOO SHAKE\t45";
gotoxy(7,14);
cout<<"7 DOUGHNUTS\t\t25";
gotoxy(7,15);
cout<<"8 DELHI CHAT\t\t35";
gotoxy(7,16);
cout<<"9 FALUDA KULFI\t40";
gotoxy(7,17);
cout<<"10 GULAB JAMUN\t10";
gotoxy(7,18);
cout<<"11 HAKKA NOODLES\t45";
gotoxy(7,19);
cout<<"12 HAM BURGER\t\t45";
gotoxy(7,20);
cout<<"13 IMARTI\t\t10";
gotoxy(7,21);
cout<<"14 INDIAN SHARBAT\t20";
gotoxy(7,22);
cout<<"15 JAPANESE JEMS\t25";
gotoxy(7,23);
cout<<"16 KACHORI\t\t15";
gotoxy(7,24);
cout<<"17 KINLEYS SODA\t20";
gotoxy(7,25);
cout<<"18 MASALA PARATHA\t20";
gotoxy(7,26);
cout<<"19 MASALA PAPAD\t20";
gotoxy(7,27);
cout<<"20 MANGO SHAKE\t25";
gotoxy(7,28);
cout<<"21 NAVRATNA KORMA\t40";
gotoxy(7,29);
cout<<"22 PANI PURI\t\t20";
gotoxy(7,30);
cout<<"23 PASTA\t\t35";
gotoxy(7,31);
cout<<"24 PIZZA\t\t40";
gotoxy(7,32);
cout<<"25 RASMALAI\t\t35";
gotoxy(7,33);
cout<<"26 RAJBHOG ICE-CREAM\t35";
gotoxy(7,34);
cout<<"27 SAMOSA\t\t15";
gotoxy(7,35);
cout<<"28 SWEET CORN SOUP\t40";
gotoxy(7,36);
cout<<"29 SPEGGATI\t\t45";
gotoxy(7,37);
cout<<"30 TOMATO SOUP\t45";
gotoxy(7,38);
cout<<"31 FINAL BILL";
gotoxy(7,40);
cout<<"ENTER THE FOOD ITEM ORDERED FROM THE ABOVE MENU.";
gotoxy(7,41);
cout<<"ENTER 31 FOR THE FINAL BILL OF THE CUSTOMER.";
}
void bil(int prod)
{
int temp; clrscr();
for(temp=0;temp<prod;temp++)
cout<<items[temp]<<endl;
cout<<"DEAR "<<rachit<<"!!\n YOUR FINAL BILL IS : "<<bill <<" RUPEES";
cout<<"\nTHANKS FOR COMING. PLEASE VISIT AGAIN SOON.";
}




_____________http://sundcs.blogspot.com/____________




//DECIMAL TO BINARY BY RACHIT AGRAWAL

#include<iostream.h>
#include<conio.h>
void main()
{
char choice;
do
{
clrscr();
int deci,temp[9];
cout<<"\nENTER A DECIMAL NUMBER: ";
cin>>deci;
for (int count=0;deci>=1;count++)
{
temp[count]=deci%2;
deci=deci/2;
}
for(count--;count>=0;count--)
cout<<temp[count];
cout<<"\nWISH TO CONTINUE?(Y/N): ";
choice=getche();
}while(choice=='y'||choice=='Y');
}



_____________http://sundcs.blogspot.com/____________




//DECIMAL TO OCTAL BY RACHIT AGRAWAL

#include<iostream.h>
#include<conio.h>
void main()
{
char choice;
do
{
clrscr();
int deci,temp[9];
cout<<"\nENTER A DECIMAL NUMBER: ";
cin>>deci;
for (int count=0;deci>=1;count++)
{
temp[count]=deci%8;
deci=deci/8;
}
for(count--;count>=0;count--)
cout<<temp[count];
cout<<"\nWISH TO CONTINUE?(Y/N): ";
choice=getche();
}while(choice=='y'||choice=='Y');
}



_____________http://sundcs.blogspot.com/____________




//DECIMAL TO HEXADECIMAL BY RACHIT AGRAWAL

#include<iostream.h>
#include<conio.h>
void main()
{
char choice;
do
{
clrscr();
long deci,temp[9];
char result[9]={0};
cout<<"\nENTER A DECIMAL NUMBER: ";
cin>>deci;
for (int count=0;deci>=1;count++)
{
temp[count]=deci%16;
deci=deci/16;
if(temp[count]>9)
{
switch(temp[count])
{
case 10:result[count]='A';
break;
case 11:result[count]='B';
break;
case 12:result[count]='C';
break;
case 13:result[count]='D';
break;
case 14:result[count]='E';
break;
case 15:result[count]='F';
break;
}
}
else
{
result[count]=temp[count]+48;
}
}
cout<<"\n";
for(count=count-1; count>=0;count--)
cout<<result[count];
cout<<"\nWISH TO CONTINUE?(Y/N): ";
choice=getch();
}while(choice=='y'||choice=='Y');
}



_____________http://sundcs.blogspot.com/____________




//BINARY TO DECIMAL

#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{
clrscr();
int bin, digit, a=0, deci=0;
cout<<"\nENTER A BINARY NUMBER : ";
cin>>bin;
for(int count=0;bin>=1;count++)
{
digit=bin%10;
while(digit>1)
{
cout<<"\nOOPS!!! ERROR. RE-ENTER : ";
cin>>bin;
digit=bin%10;
}
a=digit*pow(2,count);
deci+=a;
bin/=10;
}
cout<<"\nTHE DECIMAL NUMBER IS : "<<deci;
getch();
}



_____________http://sundcs.blogspot.com/____________




//BINARY TO OCTAL

#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{
clrscr();
int bin, digit, a=0, deci=0, octa[9];;
cout<<"\nENTER A BINARY NUMBER : ";
cin>>bin;
for(int count=0;bin>=1;count++)
{
digit=bin%10;
while(digit>1)
{
cout<<"\nOOPS!!! ERROR. RE-ENTER : ";
cin>>bin;
digit=bin%10;
}
a=digit*pow(2,count);
deci+=a;
bin/=10;
}
for (count=0;deci>=1;count++)
{
octa[count]=deci%8;
deci=deci/8;
}
for(count--;count>=0;count--)
cout<<octa[count];
getch();
}



_____________http://sundcs.blogspot.com/____________




//BINARY TO HEXADECIMAL

#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{
clrscr();
int bin, digit, a=0, deci=0,long temp[9]; char result[9];
cout<<"\nENTER A BINARY NUMBER : ";
cin>>bin;
for(int count=0;bin>=1;count++)
{
digit=bin%10;
while(digit>1)
{
cout<<"\nOOPS!!! ERROR. RE-ENTER : ";
cin>>bin;
digit=bin%10;
}
a=digit*pow(2,count);
deci+=a;
bin/=10;
}
for (count1=0;deci>=1;count1++)
{
temp[count1]=deci%16;
deci=deci/16;
if(temp[count1]>9)
{
switch(temp[count1])
{
case 10:result[count1]='A';
break;
case 11:result[count1]='B';
break;
case 12:result[count1]='C';
break;
case 13:result[count1]='D';
break;
case 14:result[count1]='E';
break;
case 15:result[count1]='F';
break;
}
}
else
{
result[count1]=temp[count1]+48;
}
}
cout<<"\n";
for(count=count-1; count>=0;count--)
cout<<result[count];
getch();
}



_____________http://sundcs.blogspot.com/____________




//OCTAL TO DECIMAL

#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{
clrscr();
int oct, digit, a=0, deci=0;
cout<<"\nENTER A OCTAL NUMBER : ";
cin>>oct;
for(int count=0;oct>=1;count++)
{
digit=oct%10;
while(digit>7)
{
cout<<"\nOOPS!!! ERROR. RE-ENTER : ";
cin>>oct;
digit=oct%10;
}
a=digit*pow(8,count);
deci+=a;
oct/=10;
}
cout<<"\nTHE DECIMAL NUMBER IS : "<<deci;
getch();
}



_____________http://sundcs.blogspot.com/____________




//OCTAL TO BINARY

#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{
clrscr();
int oct, digit, a=0, deci=0;
cout<<"\nENTER A OCTAL NUMBER : ";
cin>>oct;
for(int count=0;oct>=1;count++)
{
digit=oct%10;
while(digit>7)
{
cout<<"\nOOPS!!! ERROR. RE-ENTER : ";
cin>>oct;
digit=oct%10;
}
a=digit*pow(8,count);
deci+=a;
oct/=10;
}
int temp[9];
for (count=0;deci>=1;count++)
{
temp[count]=deci%2;
deci=deci/2;
}
for(count--;count>=0;count--)
cout<<temp[count];
getch();
}



_____________http://sundcs.blogspot.com/____________




//OCTAL TO HEXADECIMAL

#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{
clrscr();
long oct, digit, a=0, deci=0,temp[9];;
cout<<"\nENTER A OCTAL NUMBER : ";
cin>>oct;
for(int count=0;oct>=1;count++)
{
digit=oct%10;
while(digit>7)
{
cout<<"\nOOPS!!! ERROR. RE-ENTER : ";
cin>>oct;
digit=oct%10;
}
a=digit*pow(8,count);
deci+=a;
oct/=10;
}
char result[9]={0};
for (count=0;deci>=1;count++)
{
temp[count]=deci%16;
deci=deci/16;
if(temp[count]>9)
{
switch(temp[count])
{
case 10:result[count]='A';
break;
case 11:result[count]='B';
break;
case 12:result[count]='C';
break;
case 13:result[count]='D';
break;
case 14:result[count]='E';
break;
case 15:result[count]='F';
break;
}
}
else
{
result[count]=temp[count]+48;
}
}
cout<<"\n";
for(count=count-1; count>=0;count--)
cout<<result[count];
getch();
}



_____________http://sundcs.blogspot.com/____________




//HEXADECIMAL TO DECIMAL

#include<iostream.h>
#include<conio.h>
#include<stdlib.h>
#include<math.h>
#include<ctype.h>
#include<process.h>
void main()
{
clrscr();
char hex[8];
long temp[8],sum=0;
cin>>hex;
for(int i=0;hex[i]!='\0';i++)
{
if(isdigit(hex[i]))
temp[i]=hex[i]-48;
else if(isalpha(hex[i]))
{
switch(hex[i])
{
case 'A':temp[i]=10;break;
case 'B':temp[i]=11;break;
case 'C':temp[i]=12;break;
case 'D':temp[i]=13;break;
case 'E':temp[i]=14;break;
case 'F':temp[i]=15;break;
}
}
}
i--;
for(int x=0;i>=0;i--, x++)
sum=sum+(temp[i]*pow(16,x));
cout<<"\n\n"<<sum;
getch();
}



_____________http://sundcs.blogspot.com/____________




//HEXADECIMAL TO BINARY

#include<iostream.h>
#include<conio.h>
#include<stdlib.h>
#include<math.h>
#include<ctype.h>
#include<process.h>
void main()
{
clrscr();
char hex[8];
long temp[8],sum=0;
cin>>hex;
for(int i=0;hex[i]!='\0';i++)
{
if(isdigit(hex[i]))
temp[i]=hex[i]-48;
else if(isalpha(hex[i]))
{
switch(hex[i])
{
case 'A':temp[i]=10;break;
case 'B':temp[i]=11;break;
case 'C':temp[i]=12;break;
case 'D':temp[i]=13;break;
case 'E':temp[i]=14;break;
case 'F':temp[i]=15;break;
}
}
}
i--;
for(int x=0;i>=0;i--, x++)
sum=sum+(temp[i]*pow(16,x));
long t[25];
for (int count=0;sum>=1;count++)
{
t[count]=sum%2;
sum=sum/2;
}
for(count--;count>=0;count--)
cout<<t[count];
getch();
}



_____________http://sundcs.blogspot.com/____________





//HEXADECIMAL TO OCTAL

#include<iostream.h>
#include<conio.h>
#include<stdlib.h>
#include<math.h>
#include<ctype.h>
#include<process.h>
void main()
{
clrscr();
char hex[8];
long temp[8],sum=0;
cin>>hex;
for(int i=0;hex[i]!='\0';i++)
{
if(isdigit(hex[i]))
temp[i]=hex[i]-48;
else if(isalpha(hex[i]))
{
switch(hex[i])
{
case 'A':temp[i]=10;break;
case 'B':temp[i]=11;break;
case 'C':temp[i]=12;break;
case 'D':temp[i]=13;break;
case 'E':temp[i]=14;break;
case 'F':temp[i]=15;break;
}
}
}
i--;
for(int x=0;i>=0;i--, x++)
sum=sum+(temp[i]*pow(16,x));
long t[25];
for (int count=0;sum>=1;count++)
{
t[count]=sum%8;
sum=sum/8;
}
for(count--;count>=0;count--)
cout<<t[count];
getch();
}


_____________http://sundcs.blogspot.com/____________

No comments:

Post a Comment