I am using Turbo C++ 3.0.
Things to be noted :
1.) I am very new to C++
2.) I can only use the above said compiler.
3.) List, vector, functions, classes, file-handling, structures, templates and objects cannot be used in the program as per my assignment.
Here's my Code:
#include <iostream.h>
#include <conio.h>
#include <time.h>
#include <string.h>
#include <stdlib.h>
int main()
{
char option;
float p,b,x,y,z,v,a,subtotal=0,price[100],quant[100],total,cash=0,change,peices=0,receipt,disc,net[100],products;
char* items[100];
START:
clrscr();
textcolor(WHITE);
textbackground(BLACK);
time_t now = time(0);
tm *ltm = localtime(&now);
srand( (unsigned)time( NULL ) );
receipt=rand();
gotoxy(50, 4);
cout<<"WELCOME";
gotoxy(52, 7);
cout<<"TO";
gotoxy(49, 10);
cout<<"BIG BAZAAR";
gotoxy(45, 16);
cout<<"A. Create New Invoice";
gotoxy(45, 19);
cout<<"B. View Last Invoice";
gotoxy(45, 22);
cout<<"C. Exit\n";
gotoxy(45, 25);
option=getch();
if(option=='a'||option=='A')
{
if(items[0]!=NULL)
{
for(p=0;p<10;p++)
{
items[p]=NULL;
}
}
cout<<"How Many products do you want to purchase ? :";
cin>>products;
clrscr();
gotoxy(35,0);
cout<<" ";
gotoxy(35,1);
cout<<"Retail Invoice";
gotoxy(35,2);
cout<<"Big Bazaar(FUTURE VALUE RETAIL LTD.)";
gotoxy(35,4);
cout<<"Vasant Square Mall\n";
gotoxy(35,6);
cout<<"Plot No.= 8, Community Centre,\n";
gotoxy(35,8);
cout<<"Sec B, Vasant Kunj, New Delhi-110070\n";
gotoxy(35,10);
cout<<"Tel No.: 011-46000786";
gotoxy(35,12);
cout<<"Helpline : 1800 200 2255";
gotoxy(30,14);
cout<<"************************************************";
gotoxy(30,15);
cout<<"*";
gotoxy(77,15);
cout<<"*";
gotoxy(32,15);
cout<<"ITEM DESCRIPTION QTY AMT NET AMT";
for(p=0,y=16,x=32,z=52,a=61,b=68;p<products;y++,p++)
{
gotoxy(x,y);
cin>>items[p];
gotoxy(z,y);
cin>>quant[p];
gotoxy(a,y);
cin>>price[p];
net[p]=price[p]*quant[p];
gotoxy(b,y);
cout<<net[p];
subtotal=net[p]+subtotal;
peices=quant[p]+peices;
if(p!=products)
{
gotoxy(30,y);
cout<<"*";
gotoxy(77,y);
cout<<"*";
}
}
gotoxy(30,y);
cout<<"*";
gotoxy(77,y);
cout<<"*";
gotoxy(30,y+1);
cout<<"************************************************";
gotoxy(31,y+2);
cout<<"Subtotal Rs "<<subtotal;
gotoxy(31,y+3);
cout<<"VAT 12.5%";
total= (subtotal*12.5)/100+subtotal;
gotoxy(70,y+4);
cout<<"*****";
if(subtotal<4000)
{
disc=0;
total-=disc;
}
if(subtotal>=4000)
{
disc=100;
total-=disc;
}
if(subtotal>=10000)
{
disc=1000;
total-=disc;
}
if(subtotal>=50000)
{
disc=5000;
total-=disc;
}
gotoxy(31,y+5);
cout<<"Discount Rs "<<disc;
gotoxy(31,y+6);
cout<<"TOTAL AMOUNT Rs "<<total;
gotoxy(31,y+7);
cout<<"Cash Given Rs ";
cin>>cash;
change=cash-total;
gotoxy(31,y+8);
cout<<"Change Due Rs "<<change;
gotoxy(31,y+9);
cout<<"Peices Purchased :"<<peices;
gotoxy(31,y+11);
cout<<"Receipt No.: "<<receipt;
gotoxy(31,y+12);
cout<<"Receipt Date and Time: "<<ltm->tm_mday<<"/"<< 1 + ltm->tm_mon<<"/"<<1900 + ltm->tm_year<<" "<< 1 + ltm->tm_hour << ":"<<1 + ltm->tm_min << ":"<< 1 + ltm->tm_sec << endl;
gotoxy(31,y+14);
cout<<"THANKS FOR SHOPPING FROM BIG BAZAAR\n";
gotoxy(31,y+15);
cout<<"INDIA KA NAYA BAZAAR!";
getch();
goto START;
}
if(option=='b'||option=='B')
{
clrscr();
if(cash==0)
{
cout<<"No invoice was created. \nPlease create a new one.";
getch();
goto START;
}
else
{
gotoxy(35,0);
cout<<"Retail Invoice\n";
gotoxy(35,2);
cout<<"Big Bazaar(FUTURE VALUE RETAIL LTD.)\n";
gotoxy(35,4);
cout<<"Vasant Square Mall\n";
gotoxy(35,6);
cout<<"Plot No.= 8, Community Centre,\n";
gotoxy(35,8);
cout<<"Sec B, Vasant Kunj, New Delhi-110070\n";
gotoxy(35,10);
cout<<"Tel No.: 011-46000786";
gotoxy(35,12);
cout<<"Helpline : 1800 200 2255";
gotoxy(30,14);
cout<<"************************************************";
gotoxy(30,15);
cout<<"*";
gotoxy(77,15);
cout<<"*";
gotoxy(32,15);
cout<<"ITEM DESCRIPTION QTY AMT NET AMT";
for(p=0,y=16,x=32,z=52,a=61,b=68;p<100;y++,p++)
{
if(items[p]==NULL)
{
gotoxy(30,y);
cout<<"*";
gotoxy(77,y);
cout<<"*";
break;
}
else
{
gotoxy(30,y);
cout<<"*";
gotoxy(77,y);
cout<<"*";
}
gotoxy(x,y);
cout<<items[p];
gotoxy(z,y);
cout<<quant[p];
gotoxy(a,y);
cout<<price[p];
gotoxy(b,y);
cout<<net[p];
}
gotoxy(30,y);
cout<<"************************************************";
gotoxy(31,y+2);
cout<<"Subtotal Rs "<<subtotal;
gotoxy(31,y+3);
cout<<"VAT 12.5%";
gotoxy(70,y+4);
cout<<"*****";
gotoxy(31,y+5);
cout<<"Discount Rs "<<disc;
gotoxy(31,y+6);
cout<<"TOTAL AMOUNT Rs "<<total;
gotoxy(31,y+7);
cout<<"Cash Given Rs "<<cash;
gotoxy(31,y+8);
cout<<"Change Due Rs "<<change;
gotoxy(31,y+9);
cout<<"Peices Purchased :"<<peices;
gotoxy(31,y+11);
cout<<"Receipt No.: "<<receipt;
gotoxy(31,y+12);
cout<<"Receipt Date and Time: "<<ltm->tm_mday<<"/"<< 1 + ltm->tm_mon<<"/"<<1900 + ltm->tm_year<<" "<< 1 + ltm->tm_hour << ":"<<1 + ltm->tm_min << ":"<< 1 + ltm->tm_sec << endl;
gotoxy(31,y+14);
cout<<"THANKS FOR SHOPPING FROM BIG BAZAAR\n";
gotoxy(31,y+15);
cout<<"INDIA KA NAYA BAZAAR!";
getch();
goto START;
}
}
if(option=='c'||option=='C')
{ char yn;
cout<<"\nDo You Really Want To Exit(y/n)";
cin>>yn;
if(yn=='y')
{
return 0;
}
if(yn=='n')
{
goto START;
}
}
else
{
clrscr();
cout<<"Option Entered is incorrect\n Please try again.";
getch();
goto START;
}
return 0;
}
Problem faced: Only one product can be entered after which the program closes on its own.