I have to submit this project by this weekend.Please help me.
mrsrinath 0 Newbie Poster
The attachment preview is chopped off after the first 10 KB. Please download the entire file.
#include<iostream.h>
#include<conio.h>
#include<iomanip.h>
#include<graphics.h>
#include<dos.h>
#include<math.h>
#include<process.h>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<fstream.h>
struct chess
{
int pc;
char pe;};
int checkb(int ipr,int ipc,int fpr,int fpc,char ch[][8],int pc[][8],int ip3,int ip4)
{ int i,j;
for(i=ipr-1,j=ipc-1;i<fpr&&j<fpc;i++,j--)
if(ch[i][j]!='A')
// if(pc[ip3][ip4]==pc[i][j])
return 1;
return 0;
}
int bishop(int ip3,int ip4, int fp3, int fp4,char ch[][8],int pc[][8])
{
int i,j;
if(fp3-ip3!=fp4-ip4&&fp3-ip3!=ip4-fp4)
return 1;
if(ip3<fp3)
{ if(ip4<fp4)
if(checkb(ip3,ip4,fp3,fp4,ch,pc,ip3,ip4)==1)
return 1;
if(fp4<ip4)
if(checkb(ip3,fp4,fp3,ip4,ch,pc,ip3,ip4)==1)
return 1;
}
if(fp3<ip3)
{
if(ip4<fp4)
if(checkb(fp3,ip4,ip3,fp4,ch,pc,ip3,ip4)==1)
return 1;
if(fp4<ip4)
if(checkb(fp3,fp4,ip3,ip4,ch,pc,ip3,ip4)==1)
return 1;
}
else
if(pc[ip3][ip4]==pc[fp3][fp4])
return 1;
else
return 0;
}
int horse(int ip3,int ip4,int fp3,int fp4,char ch[][8],int pc[][8])
{
int i,sum=0;
if(ip3!=fp3-1&&ip3!=fp3+1&&ip4!=fp4+1&&ip4!=fp4-1)
sum++;
if(ip3!=fp3+2&&ip3!=fp3-2&&ip4!=fp4+2&&ip4!=fp4-2)
sum++;
if(sum>=1)
return 1;
else
if(pc[ip3][ip4]==pc[fp3][fp4])
return 1;
else
return 0;
}
int rook(int ip3,int ip4,int fp3,int fp4,char ch[][8],int pc[][8])
{
int i;
if(ip3!=fp3&&ip4!=fp4)
return 1;
if(ip3==fp3)
{
if(ip4<fp4)
for(i=ip4+1;i<fp4;i++)
if(ch[ip3][i]!='A')
// if(pc[ip3][ip4]==pc[ip3][i])
return 1;
if(fp4<ip4)
for(i=fp4+1;i<ip4;i++)
if(ch[ip3][i]!='A')
//if(pc[ip3][ip4]==pc[ip3][i])
return 1;
}
else
if(ip4==fp4)
{
if(ip3<fp3)
for(i=ip3+1;i<fp3;i++)
if(ch[i][ip4]!='A')
//if(pc[ip3][ip4]==pc[i][ip4])
return 1;
if(fp3<ip3)
for(i=fp3+1;i<ip3;i++)
if(ch[i][ip4]!='A')
//if(pc[ip3][ip4]==pc[i][ip4])
return 1;
}
else
if(pc[ip3][ip4]==pc[fp3][fp4])
return 1;
else
return 0;
}
class place
{
public:
char name[50];
char type[50];
int lotno;
int own;
float lotvalue;
float sharebuy;
float sharesell;
int nobuild;
float buildvalue;
float total;
place()
{
own=0;
buildvalue=0;
}
}lot[22];
class player
{public:
int posn;
float cash;
float lots[20];
float lotval;
float build[20];
float buildval;
float share[20];
float shareval;
float loan;
float salary;
float total;
void disposn(char a);
void displayer(char a);
player()
{
posn=1;
cash=5000000;
for(int i=0;i<20;i++)
{
lots[i]=0;
build[i]=0;
share[i]=0;
}
lotval=0;
buildval=0;
shareval=0;
loan=0;
salary=30000;
total=5000000;
}
void totalcalc(int n);
};
void player :: totalcalc(int n)
{
float sharecost=0,lvalue=0,bvalue=0;
for(int i=0;i<20;i++)
{
sharecost+=share[i]*lot[i].sharesell;
if(lot[i].own==n)
{lvalue+=lot[i].lotvalue;
bvalue+=lot[i].buildvalue;
}
}
total=cash+sharecost+lvalue+bvalue-loan;
}
void player :: disposn(char a)
{ char b[3];
b[0]=a;
b[1]='\0';
settextstyle(7,0,0);
if (posn>=1&&posn<=6)
outtextxy(45+50*(posn-1),15,b);
else
if(posn>=6&&posn<=11)
outtextxy(295,15+50*(posn-6),b);
else
if(posn>=11&&posn<=16)
outtextxy(295-50*(posn-11),265,b);
else
if(posn>=16)
outtextxy(45,265-50*(posn-16),b);
}
void bothdisp(int posn)
{ settextstyle(7,0,0);
char a[3],b[3];
a[0]='A';
a[1]='\0';
b[0]='B';
b[1]='\0';
if (posn>=1&&posn<=6)
{ outtextxy(45+50*(posn-1)-15,15,a);
outtextxy(45+50*(posn-1)+12,15,b);}
else
if(posn>=6&&posn<=11)
{ outtextxy(295-15,15+50*(posn-6),a);
outtextxy(295+12,15+50*(posn-6),b);}
else
if(posn>=11&&posn<=16)
{outtextxy(295-50*(posn-11)-15,265,a);
outtextxy(295-50*(posn-11)+12,265,b);}
else
if(posn>=16)
{ outtextxy(45-15,265-50*(posn-16),a);
outtextxy(45+12,265-50*(posn-16),b);}
}
void lotinitialise()
{
strcpy(lot[0].name,"1. Cafe Charm");
lot[0].sharebuy=68;
lot[0].sharesell=floor( (lot[0].sharebuy*97)/100);
lot[0].lotvalue=600000;
lot[0].lotno=0;
int i=1,j=0;
strcpy(lot[i].name,"2. Pizza Almara");
lot[i].sharebuy=lot[j].sharebuy+lot[j].sharebuy/10;
lot[i].sharesell=floor( (lot[i].sharebuy*97)/100);
lot[i].lotvalue=(110.0*lot[j].lotvalue)/100;
lot[i].lotno=i;
i++;j++;
strcpy(lot[i].name,"3. Trees and Woods");
lot[i].sharebuy=lot[j].sharebuy+lot[j].sharebuy/10;
lot[i].sharesell=floor( (lot[i].sharebuy*97)/100);
lot[i].lotvalue=(110.0*lot[j].lotvalue)/100;
lot[i].lotno=i;
i++;j++;
strcpy(lot[i].name,"4. Danddy Furnitures");
lot[i].sharebuy=lot[j].sharebuy+lot[j].sharebuy/10;
lot[i].sharesell=floor( (lot[i].sharebuy*97)/100);
lot[i].lotvalue=(110.0*lot[j].lotvalue)/100;
lot[i].lotno=i;
i++;j++;
strcpy(lot[i].name,"5. Stassi Oil ");
lot[i].sharebuy=lot[j].sharebuy+lot[j].sharebuy/10;
lot[i].sharesell=floor( (lot[i].sharebuy*97)/100);
lot[i].lotvalue=(110.0*lot[j].lotvalue)/100;
lot[i].lotno=i;
i++;j++;
strcpy(lot[i].name,"6. Decent Harry");
lot[i].sharebuy=lot[j].sharebuy+lot[j].sharebuy/10;
lot[i].sharesell=floor( (lot[i].sharebuy*97)/100);
lot[i].lotvalue=(110.0*lot[j].lotvalue)/100;
lot[i].lotno=i;
i++;j++;
strcpy(lot[i].name,"7. Mclaven Tavern");
lot[i].sharebuy=lot[j].sharebuy+lot[j].sharebuy/10;
lot[i].sharesell=floor( (lot[i].sharebuy*97)/100);
lot[i].lotvalue=(110.0*lot[j].lotvalue)/100;
lot[i].lotno=i;
i++;j++;
strcpy(lot[i].name,"8. Others clothings");
lot[i].sharebuy=lot[j].sharebuy+lot[j].sharebuy/10;
lot[i].sharesell=floor( (lot[i].sharebuy*97)/100);
lot[i].lotvalue=(110.0*lot[j].lotvalue)/100;
lot[i].lotno=i;
i++;j++;
strcpy(lot[i].name,"9. Kwiki Mart");
lot[i].sharebuy=lot[j].sharebuy+lot[j].sharebuy/10;
lot[i].sharesell=floor( (lot[i].sharebuy*97)/100);
lot[i].lotvalue=(110.0*lot[j].lotvalue)/100;
lot[i].lotno=i;
i++;j++;
strcpy(lot[i].name,"10. Grand Threatre"); //i=9;
lot[i].sharebuy=lot[j].sharebuy+lot[j].sharebuy/10;
lot[i].sharesell=floor( (lot[i].sharebuy*97)/100);
lot[i].lotvalue=(110.0*lot[j].lotvalue)/100;
lot[i].lotno=i;
i++;j++;
strcpy(lot[i].name,"11. Homemakers"); //i=10;
lot[i].sharebuy=lot[j].sharebuy+lot[j].sharebuy/10;
lot[i].sharesell=floor( (lot[i].sharebuy*97)/100);
lot[i].lotvalue=(110.0*lot[j].lotvalue)/100;
lot[i].lotno=i;
i++;j++;
strcpy(lot[i].name,"12. Bouteq Resturant "); //i=11;
lot[i].sharebuy=lot[j].sharebuy+lot[j].sharebuy/10;
lot[i].sharesell=floor( (lot[i].sharebuy*97)/100);
lot[i].lotvalue=(110.0*lot[j].lotvalue)/100;
lot[i].lotno=i;
i++;j++;
strcpy(lot[i].name,"13. Bob's Car"); //i=12;
lot[i].sharebuy=lot[j].sharebuy+lot[j].sharebuy/10;
lot[i].sharesell=floor( (lot[i].sharebuy*97)/100);
lot[i].lotvalue=(110.0*lot[j].lotvalue)/100;
lot[i].lotno=i;
i++;j++;
strcpy(lot[i].name,"14. Flying Saucer"); //i=13;
lot[i].sharebuy=lot[j].sharebuy+lot[j].sharebuy/10;
lot[i].sharesell=floor( (lot[i].sharebuy*97)/100);
lot[i].lotvalue=(110.0*lot[j].lotvalue)/100;
lot[i].lotno=i;
i++;j++;
strcpy(lot[i].name,"15. Airways"); //i=14;
lot[i].sharebuy=lot[j].sharebuy+lot[j].sharebuy/10;
lot[i].sharesell=floor( (lot[i].sharebuy*97)/100);
lot[i].lotvalue=(110.0*lot[j].lotvalue)/100;
lot[i].lotno=i;
i++;j++;
strcpy(lot[i].name,"16. Share Invest"); //i=15;
lot[i].sharebuy=lot[j].sharebuy+lot[j].sharebuy/10;
lot[i].sharesell=floor( (lot[i].sharebuy*97)/100);
lot[i].lotvalue=(110.0*lot[j].lotvalue)/100;
lot[i].lotno=i;
i++;j++;
strcpy(lot[i].name,"17. Banana Computers"); //i=16;
lot[i].sharebuy=lot[j].sharebuy+lot[j].sharebuy/10;
lot[i].sharesell=floor( (lot[i].sharebuy*97)/100);
lot[i].lotvalue=(110.0*lot[j].lotvalue)/100;
lot[i].lotno=i;
i++;j++;
strcpy(lot[i].name,"18. Millinaire bank"); //i=17;
lot[i].sharebuy=lot[j].sharebuy+lot[j].sharebuy/10;
lot[i].sharesell=floor( (lot[i].sharebuy*97)/100);
lot[i].lotvalue=(110.0*lot[j].lotvalue)/100;
lot[i].lotno=i;
i++;j++;
strcpy(lot[i].name,"19. On & Off"); //i=18;
lot[i].sharebuy=lot[j].sharebuy+lot[j].sharebuy/10;
lot[i].sharesell=floor( (lot[i].sharebuy*97)/100);
lot[i].lotvalue=(110.0*lot[j].lotvalue)/100;
lot[i].lotno=i;
i++;j++;
strcpy(lot[i].name,"20. Electromania"); //i=19;
lot[i].sharebuy=lot[j].sharebuy+lot[j].sharebuy/10;
lot[i].sharesell=floor( (lot[i].sharebuy*97)/100);
lot[i].lotvalue=(110.0*lot[j].lotvalue)/100;
lot[i].lotno=i;
i++;j++;
}
void outstockmarket()
{
outtextxy(340,180,"Company");
outtextxy(510,180,"Buy");
outtextxy(590,180,"Sell");
for(int i=0;i<20;i++)
{
outtextxy(340,200+(i*13),lot[i].name);
char out[30];
sprintf(out,"%f",lot[i].sharebuy);
for(int j=0;j<strlen(out);j++)
if(out[j]=='.')
out[j]='\0';
outtextxy(510,200+(i*13),out);
sprintf(out,"%f",lot[i].sharesell);
for(j=0;j<strlen(out);j++)
if(out[j]=='.')
out[j]='\0';
outtextxy(590,200+(i*13),out);
}
}
void inflate()
{
int rate=random(7)-2;
int randomlot=random(20);
lot[randomlot].sharebuy+=(rate*lot[randomlot].sharebuy)/100.0;
lot[randomlot].sharesell=floor( (lot[randomlot].sharebuy*97)/100);
lot[randomlot].lotvalue+=(1.0*rate*lot[randomlot].lotvalue)/100;
}
void outplayerinfo(player a,player b)
{ settextstyle(0,0,1);
line(480,0,480,170);
line(380,140,480,140);
line(530,140,640,140);
line(332,170,640,170);
outtextxy(370,0,"Player 1");
outtextxy(530,0,"Player 2");
out
Clinton Portis 211 Practically a Posting Shark
1. What specifically about the project is giving you problems?
2. Why did you take this course if you didn't want to make some sort of effort to learn the material..??!
mrsrinath 0 Newbie Poster
1.It creates a text file through the program for storing the data taken as input and
the file gets created but the data is not getting stored for him.
Both the files are getting created.The second file(a binary file) is working
separately but not alongwith the first file(a text file,which is used to store
the name in which it has to be saved).So,the problem is with the text file.Certain
changes may be done in order to make it work.Some lines can also be added
Please find the details of the error in his program.
gautiram.cpp contains the program for the entire project. The other
program contains the part which is not working.It deals with saving the
information in a file and when the file is again opened ,the saved
information does not exist.The file can either be a binary file or a
text file.I don't understand whether there is any problem while saving
the information or while opening the file.In the original program
(gautiram.cpp),this part is in the 1027th line in which the first
file(namesave)is a binary file whereas in the other program it is a text
file.
2.I was admitted to hospital for a while and had lots of family problems at that time.
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.