Description: A Program for a Music shop for sale of music albums.
Compiler: Turbo C++ 3.0Author: Pranav Vats
Password:- EMINEM
*/
#include<iostream.h>
#include<conio.h>
#include<string.h>
#include<stdio.h>
#include<ctype.h>
#include<stdlib.h>
//Global variables
int alb_present=0,np=6;
char p[20],cp[20]="EMINEM";
void frontpage();
void fmenu(); //Main Menu
void pass();
void changepass();
void store();
void displayalbum();
void billinput();
void billoutput();
struct bill
{
char name[26],itemname[50],artist[26];
int itemcode,ch;
float price,qty,disper,disval,netprice; //disper=discount percent , disval=discount value ,ch=pay choice
void pay(int);
float cal();
}b;
struct album
{
char name[50],artist[26];
int albumcode;
float price;
void insertalbum();
}al[15];
int main()
{
clrscr();
frontpage();
pass();
clrscr();
fmenu();
getch();
return 0;
}
void fmenu()
{
int fch,no,delcode,found=0,choice;
clrscr();
gotoxy(30,1);
cout<<"The_Music_Shop";
cout<<"\n\t\t\t*** Welcome ***\n\nPlease choose your desired action\n";
cout<<"\n1.Store\n2.Add New Album\n3.Delete An Album\n4.Change password\n5.exit";
gotoxy(25,15);
cout<<"Enter Your Choice... ";
cin>>fch;
switch(fch)
{
case 1: store();
getch();
fmenu();
break;
case 2: clrscr();
gotoxy(30,1);
cout<<"*** Welcome to Insertion Sector ***\n\n";
cout<<"Please specify the number of albums you want to insert : ";
cin>>no;
for(int i=alb_present;i<no+alb_present;i++)
{
cout<<"\n"<<i+1<<" ";
al[i].insertalbum();
al[i].albumcode=i+1;
cout<<"Album Code Alloted : "<<al[i].albumcode<<"\n";
}
alb_present+=no;
cout<<"\n\t\tCONGRATULATION'S you have added "<<no<<" Albums To Our store\n\nPress any key to return to main menu...";
getch();
fmenu();
break;
case 3: clrscr();
gotoxy(30,1);
cout<<"*** Welcome to Deletion Sector ***\n\n";
do
{
cout<<"\nPlease enter the album code of the album to delete : ";
cin>>delcode;
for(i=0;i<alb_present;i++)
{
if(delcode==al[i].albumcode)
{
found=1;
break;
}
}
if(found)
{
for(;i<alb_present;i++)
{
al[i]=al[i+1];
al[i].albumcode=al[i+1].albumcode;
}
}
if(!found)
{
cout<<"The code you entered is not present or has already been deleted.";
}
alb_present-=1;
cout<<"Do you wish to continue deleting more albums(y/n)";
choice=getch();
}while(choice=='y'||choice=='Y');
cout<<"\n\t\t\t\tDeletion Succesful\n\n\t\tPress any key to return to main menu...";
getch();
fmenu();
break;
case 4:changepass();
break;
case 5: exit(0);
break;
}
}
void pass()
{
clrscr();
gotoxy(30,1);
cout<<"SECURITY CHECK";
gotoxy(25,12);
cout<<"Please Enter the Password : ";
for(int i=0;i<np;i++)
{
p[i]=getch();
cout<<"*";
}
p[i]='\0';
if(strcmp(p,cp)==0)
{
clrscr();
gotoxy(31,12);
cout<<" Access Granted";
gotoxy(31,24);
cout<<(char)169<<" Made by Pranav Vats";
getch();
}
else
{
clrscr();
gotoxy(30,12);
cout<<"ACCESS DENIED\nPress any key to exit..";
getch();
exit(0);
}
}
void changepass()
{
pass();
clrscr();
char temppass[20],confirmpass[20];
gotoxy(30,1);
cout<<"Change Password";
cout<<"\n\nEnter no. of Characters in your New password : ";
cin>>np;
cout<<"\n\nEnter Your new password : ";
for(int i=0;i<np;i++)
{
temppass[i]=getch();
cout<<"*";
}
temppass[i]='\0';
cout<<"\nRe-enter your password : ";
for(i=0;i<np;i++)
{
confirmpass[i]=getch();
cout<<"*";
}
confirmpass[i]='\0';
if(strcmp(temppass,confirmpass)==0)
{
for(i=0;i<np;i++)
{
cp[i]=temppass[i];
}
cout<<"\n\n\n\t\t\t***Password Successfully Changed***"<<"\n\n\t\tPress any key to return to main menu...";
}
else
{
cout<<"\n\n\n\t\t\t***Passwords Didn't Match***"<<"\n\n\t\tPress any key to return to main menu";
}
getch();
fmenu();
}
void album::insertalbum()
{
cout<<"Name of Album : ";
gets(name);
cout<<" Name of the Artist : ";
gets(artist);
cout<<" Price : ";
cin>>price;
}
void displayalbum()
{
int i;
for(i=0;i<alb_present;i++)
{
cout<<"\n\n\n"<<i+1<<". Name of album : ";
puts(al[i].name);
cout<<" Name of artist : ";
puts(al[i].artist);
cout<<" Album Code : ";
cout<<al[i].albumcode<<"\n";
cout<<" Price : "<<al[i].price;
}
}
void pay(int ch) //bill
{
switch(ch)
{
case 1:cout<<"Cash";
break;
case 2:cout<<"Debit Card";
break;
case 3:cout<<"Credit Card";
break;
}
}
void billinput() //bill
{
int found=0,pchoice=0,bchoice=0,bcchoice=0;
clrscr();
cout<<"\t\t *** Welcome to The_Music_Shop ***\nPlease Provide The following details:-\n";
cout<<"\nCustomer's Name : ";
gets(b.name);
cout<<"Album Code : ";
cin>>b.itemcode;
for(int i=0;i<alb_present;i++)
{
if(b.itemcode==al[i].albumcode)
{
found=1;
break;
}
}
if(found)
{
cout<<"Price : "<<al[i].price;
}
b.price=al[i].price;
cout<<"\nName of Album : ";
puts(al[i].name);
cout<<"Name Of Artist : ";
puts(al[i].artist);
cout<<"Number of Albums : ";
cin>>b.qty;
cout<<"Discount(%) : ";
cin>>b.disper;
cout<<"Pay by(1.Cash,2.Debit card,3.Credit card) : ";
cin>>b.ch;
for(int j=1;j<=25;j++)
{
gotoxy(50,j);
cout<<"|";
}
gotoxy(55,5);
cout<<"Options:-";
gotoxy(55,6);
cout<<"1.Confirm Purchase";
gotoxy(55,7);
cout<<"2.Cancel Purchase";
cin>>pchoice;
switch(pchoice)
{
case 1:billoutput();
for(int j=1;j<=25;j++)
{
gotoxy(50,j);
cout<<"|";
}
gotoxy(55,5);
cout<<"Options:-";
gotoxy(55,6);
cout<<"1.Return to store";
gotoxy(55,7);
cout<<"2.Return to Main Menu";
gotoxy(55,8);
cout<<"3.Exit";
cin>>bchoice;
switch(bchoice)
{
case 1:store();
break;
case 2:fmenu();
break;
case 3:exit(0);
break;
}
break;
case 2:
clrscr();
gotoxy(30,12);
cout<<"PURCHASE SUCCESFULLY CANCELED";
gotoxy(30,13);
cout<<"Options:-";
gotoxy(30,14);
cout<<"1.Return to store";
gotoxy(30,15);
cout<<"2.Return to Main Menu";
gotoxy(30,16);
cout<<"3.Exit";
gotoxy(30,17);
cout<<"Enter Your choice here... ";
cin>>bcchoice;
switch(bcchoice)
{
case 1:store();
break;
case 2:fmenu();
break;
case 3:exit(0);
break;
}
break;
}
}
float cal() //bill
{
b.disval=(b.disper*(b.price*b.qty))/100;
b.netprice=b.price-b.disval;
return b.netprice;
}
void billoutput() //bill
{
clrscr();
float np;
int k,found=0;
gotoxy(11,5);
cout<<"*** Your Bill ***";
np=cal();
for(k=1;k<32;k++)
{
gotoxy(3+k,2);
cout<<"-";
}
for(k=1;k<18;k++)
{
gotoxy(3,2+k);
cout<<"|";
}
for(k=1;k<32;k++)
{
gotoxy(3+k,20);
cout<<"-";
}
for(k=1;k<18;k++)
{
gotoxy(35,2+k);
cout<<"|";
}
for(int i=0;i<alb_present;i++)
{
if(b.itemcode==al[i].albumcode)
{
found=1;
break;
}
}
if(found)
{
b.itemname[50]=al[i].name[50];
}
gotoxy(9,8);
cout<<"***The_Music_Shop***";
gotoxy(7,10);
cout<<"Customer's Name : ";
puts(b.name);
gotoxy(7,11);
cout<<"Album Name : ";
puts(al[i].name);
gotoxy(7,12);
cout<<"Artist Name : ";
puts(b.artist);
gotoxy(7,13);
cout<<"Quantity : ";
cout<<b.qty;
gotoxy(7,14);
cout<<"Price(1 Item) : ";
cout<<b.price;
gotoxy(7,15);
cout<<"Discount(%) : ";
cout<<b.disper;
gotoxy(7,16);
cout<<"Total : ";
cout<<np;
gotoxy(7,17);
cout<<"Paid by : ";
pay(b.ch);
gotoxy(9,19);
cout<<"*** Thank You ***";
}
void store()
{
clrscr();
int schoice;
gotoxy(30,1);
cout<<"The_Music_Store";
displayalbum();
for(int j=1;j<=25;j++)
{
gotoxy(50,j);
cout<<"|";
}
gotoxy(55,5);
cout<<"Options\n";
gotoxy(55,6);
cout<<"1.Purchase\n";
gotoxy(55,7);
cout<<"2.return to Main Menu _";
cin>>schoice;
switch(schoice)
{
case 1:billinput();
break;
case 2:fmenu();
break;
}
}
void frontpage()
{
gotoxy(30,12);
cout<<"C++ Project";
gotoxy(29,14);
cout<<"The_Music_Shop";
gotoxy(60,20);
cout<<"Pranav Vats";
gotoxy(62,21);
cout<<"XI-C";
gotoxy(63,22);
cout<<"21";
for(int k=0;k<20;k++)
{
gotoxy(26+k,17);
cout<<"*";
}
for(int j=0;j<20;j++)
{
gotoxy(26+j,9);
cout<<"*";
}
for(int i=0;i<20;i++)
{
gotoxy(26+i,8);
cout<<"_";
}
for(int n=0;n<20;n++)
{
gotoxy(26+n,18);
cout<<"_";
}
gotoxy(1,24);
cout<<"\nPress any key to proceed...";
getch();
}
0 comments:
Post a Comment