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
|
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<dos.h>
#include<string.h>
#include<windows.h>
float cash;
typedef struct
{
char title[50];
float price;
}info;
info dvd[2];
void clrscr()
{
system("cls");
}
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 dvd_lists()
{ int x;
for(x=0; x<2; x++)
{
printf("DVD Title: ");
gets(dvd[x].title);
printf("Price: ");
cin>>dvd[x].price;
cout<<"\n";
}
}
void lists_dvd()
{ int x;
clrscr();
for(x=0; x<2; x++)
{
gotoxy(30,3);
cout<<"DVD RENTAL SYSTEM";
gotoxy(5,7);
cout<<"Title";
gotoxy(25,7);
cout<<"Price";
gotoxy(5,9+x);
cout<<dvd[x].title;
gotoxy(25,9+x);
printf("%5.2f", dvd[x].price);
}
}
void menu()
{
lists_dvd();
cout<<"\n\n\nTRANSACTION\n\n\n";
cout<<"[1]Rent a DVD\n";
cout<<"[2]DVD Available\n";
cout<<"[3]Exit\n\n\n";
cout<<"Enter Transaction: ";
}
void enter_cash()
{
gotoxy(40,14);
scanf("%f",&cash);
}
void rent()
{
char title[20];
char month[10];
int date,dater, year, x, recno=-1;
float change;
lists_dvd();
printf("\n\n\nEnter Title: ");
gets(title);
for(x=0;x<2; x++)
if(!(strcmp(dvd[x].title,title)))
{
cout<<"Price: "<<dvd[x].price;
recno=x;
}
if(recno==-1)
cout<<"Not Available!" ;
else
{
for(x=0; x<2; x++)
if(!(strcmp(dvd[x].title,title)))
{
cout<<"\n\nDate Barrowed";
cout<<"\nMonth :";
scanf("%s", &month);
cout<<"Date: ";
cin>>date;
cout<<"Year: ";
cin>>year;
gotoxy(35,7);
cout<<"Barrowed DVD";
gotoxy(35,9);
cout<<"Title: "<<dvd[x].title;
gotoxy(35,10);
cout<<"Price: "<<dvd[x].price;
gotoxy(35,11);
cout<<"To be return on: ";
cout<<month;
dater= date+2;
cout<<" "<<dater;
cout<<" "<<year;
gotoxy(35,14);
cout<<"Cash: ";
do
{
enter_cash();
change= cash-dvd[x].price;
}
while(cash<dvd[x].price);
gotoxy(35,15);
cout<<"Change: ";
printf("%.2f", change);
}
}
getch();
}
main()
{
char ans;
int opt;
clrscr();
dvd_lists();
lists_dvd();
do
{
menu();
cin>>opt;
if(opt==1)
{
rent();
}
else if(opt==2);
{
lists_dvd();
}
}
while(opt>=1 && opt<=2);
getch();
return 0;
}
|