C++(cpp) project Project Name: Water Vehicle You are required to automate the fo
ID: 3773718 • Letter: C
Question
C++(cpp) project
Project Name: Water Vehicle
You are required to automate the following specifications of a water vehicle:
=>We can increase the speed of water vehicle by nitro.
=>We have a limited quantity of nitro.Quantity of nitro increase according to distance travelled.
=>There is a GPS system to find the location of a water vehicle.
=>Water vehicle have both systems to drive on road and sea.
=>Water Vehicle is armed by some Weapons which are executed by programming.(different for road and water)
Tips: Menus will be displayed.You may use different functions to handle different scenarios.
Explanation / Answer
The below is the c++ program for serving the water vehicles. Just run the below program and you will get the output:
#include<iostream.h>
#include<stdio.h>
#include<conio.h>
#include<fstream.h>
#include<stdlib.h>
#include<string.h>
#include<dos.h>
class boat
{
protected:
char pro[25];
char name[25];
char detail[500];
};
/*************************************************/
class eng:virtual public boat
{
int j,m;
public:
void see_e(void);
void add_e(void);
void serch_e(void);
};
/******************SEE******************/
void eng::see_e()
{
clrscr();
ifstream in;
in.open("menu_e.txt");
cout<<" THE LIST OF ENGINE BOAT *****************************";
j=0;
while(in)
{
delay(200);
j++;
in.getline(name,25);
if(strlen(name)>1)
cout<<" "<<j<<". "<<name<<endl;
}
in.close();
getch();
}
/******************ADD****************/
void eng::add_e()
{
ofstream out,ot;
char name[25],detail[500];
clrscr();
flushall();
ot.open("menu_e.txt",ios::app);
//cin.getline(name,25);
cout<<" ENTER THE BOAT NAME::";
gets(name);
ot<<name<<" ";
ot.close();
strcat(name,".txt");
out.open(name);
flushall();
cout<<" ENTER THE DETAILS::";
gets(detail);
out<<detail;
out.close();
}
/*****************SEARCH***************/
void eng::serch_e()
{
char name[100];
clrscr();
cout<<" ENTER THE BOAT NAME ::";
flushall();
gets(name);
cout<<" SERCHING";
for(m=0;m<8;m++)
{
delay(200);
cout<<" .";
}
strcat(name,".txt");
ifstream fin(name,ios::in);
if (!fin)
{
clrscr();
delay(100);
cout<<" THIS BOAT ISN'T INCLUDE IN THE MANU LIST.";
delay(200);
cout<<" FOR YOUR KIND INFORMATION SEE THE LIST.";
delay(300);
cout<<" *THANK YOU*";
}
else
{
clrscr();
cout<<" MESSAGE OF THIS BOAT ************************** ";
char tmp;
fin.seekg(0);
while(!fin.eof())
{
fin.get(tmp);
cout<<tmp;
delay(100);
}//cout<<fin.readbuf();
}
getch();
}
/*****************************************/
class menual:virtual public boat
{
public:
void see_m(void);
void add_m(void);
void serch_m(void);
int i,m;
};
/*********************SEE**********************/
void menual::see_m()
{
clrscr();
ifstream in;
in.open("menu_m.txt");
i=1;
cout<<" THE LIST OF MANUAL BOAT *****************************";
while(in)
{
delay(200);
in.getline(name,25);
if(strlen(name)>1)
cout<<" "<<i<<". "<<name<<endl;
i++;
}
in.close();
getch();
}
/****************ADD**************/
void menual::add_m()
{
ofstream out1,ot1;
char name[25],detail[500];
clrscr();
cout<<" ENTER THE BOAT NAME::";
flushall();
ot1.open("menu_m.txt",ios::app);
//cin.getline(name,25);
gets(name);
ot1<<name<<" ";
ot1.close();
strcat(name,".txt");
out1.open(name);
//cin.getline(detail,500);
flushall();
cout<<" ENTER THE DETAILS::";
gets(detail);
out1<<detail;
out1.close();
}
/***************SEARCH*************/
void menual:: serch_m()
{
char name[100];
clrscr();
cout<<" ENTER THE BOAT NAME ::";
flushall();
gets(name);
strcat(name,".txt");
cout<<" SERCHING";
for(m=0;m<8;m++)
{
delay(200);
cout<<" .";
}
ifstream fin(name,ios::in);
if (!fin)
{
clrscr();
delay(100);
cout<<" THIS BOAT ISN'T INCLUDE IN THE MANU LIST.";
delay(200);
cout<<" FOR YOUR KIND INFORMATION SEE THE LIST.";
delay(300);
cout<<" *THANK YOU*";
}
else
{
clrscr();
char tmp;
cout<<" MESSAGE OF THIS BOAT ************************** ";
fin.seekg(0);
while(!fin.eof())
{
fin.get(tmp);
cout<<tmp;
delay(200);
// cout<<tmp;
// fin>>tmp;
}
//cout<<fin.readbuf();
}
getch();
}
/********************PROPERTI********************/
class properti:virtual public boat
{
int m,i;
char tmp[25];
public:
void see_p(void);
void add_p(void);
void serch_p(void);
void boat_p(void);
};
/**********************************************/
void properti::see_p()
{
clrscr();
ifstream in;
in.open("menu_p.txt");
i=1;
cout<<" THE LIST OF PROPERTI *****************************";
while(in)
{
delay(200);
in.getline(name,25);
if(strlen(name)>1)
cout<<" "<<i<<". "<<name<<endl;
i++;
}
in.close();
getch();
}
/***********************************************/
void properti::boat_p()
{
char n[25],nm[25],b[25];
cout<<" ENTER THE PROPERTI::";
flushall();
gets(n);
strcpy(nm,n);
strcat(nm,".txt");
ofstream o1;
cout<<" ENTER THE BOAT NAME::";
flushall();
o1.open(nm,ios::app);
gets(b);
o1<<b<<" ";
o1.close();
}
/******************************************/
void properti::add_p()
{
ofstream outp,otp;
char name[25],detail[500];
clrscr();
cout<<" ENTER THE PROPERTI::";
flushall();
otp.open("menu_p.txt",ios::app);
//cin.getline(name,25);
gets(name);
otp<<name<<" ";
otp.close();
strcat(name,".txt");
outp.open(name);
//cin.getline(detail,500);
flushall();
cout<<" ENTER THE BOAT NAME::";
gets(detail);
outp<<detail<<" ";
outp.close();
}
/*****************************************/
void properti:: serch_p()
{
char name[100];
clrscr();
cout<<" ENTER THE PROPERTI ::";
flushall();
gets(name);
strcat(name,".txt");
cout<<" SERCHING";
for(m=0;m<8;m++)
{
delay(200);
cout<<" .";
}
ifstream fin(name,ios::in);
if (!fin)
{
clrscr();
delay(100);
cout<<" THIS PROPERTI ISN'T INCLUDE IN THE MANU LIST.";
delay(200);
cout<<" FOR YOUR KIND INFORMATION SEE THE LIST.";
delay(300);
cout<<" *THANK YOU*";
}
else
{
clrscr();
cout<<" THE LIST OF BOAT OF THIS PROPERTI ***************************************";
fin.seekg(0);
i=1;
while(!fin.eof())
{
delay(100);
fin.getline(tmp,25);
if(strlen(tmp)>1)
cout<<" "<<i<<". "<<tmp;
i++;
}
//cout<<fin.readbuf();
}
getch();
}
/*************************************************/
class f
{
public:
f();
};
f::f()
{
while(1)
{
clrscr();
cout<<" THE PROJECT IS THE SURVE OF WATER VAHICLES";
cout<<" ************************************************";
cout<<" 1.TEXT MESSAGE FOR BOAT 2.PROPERTIS OF BOAT 3.EXIT";
cout<<" CHOSE YOUR OPTION::";
int n1;
cin>>n1;
if(n1==1)
{
while(1)
{
int n2;
eng w;
clrscr();
cout<<" MESSAGE FOR BOAT **********************";
cout<<" 1.ENGINE BOAT 2.MANUAL BOAT 3.PREVIOUS MANU";
cout<<" CHOSE YOUR OPTION::";
cin>>n2;
if(n2==1)
{
while(1)
{
int n3;
char a[20][20],b[20][20];
clrscr();
cout<<" ENGINE BOAT *****************";
cout<<" 1.SEE THE LIST OF BOAT 2.ADD BOAT & DETAILS 3.PREVIOUS MANU 4.FOR SHOWING DETAILS";
cout<<" CHOSE YOUR OPTION::";
cin>>n3;
if(n3==1)
w.see_e();
else if(n3==2)
w.add_e();
else if(n3==3)
break;
else if(n3==4)
w.serch_e();
}
}
else if(n2==2)
{
while(1)
{
int n4;
menual x;
char a[20][20],b[20][20];
clrscr();
cout<<" MANUAL BOAT *****************";
cout<<" 1.SEE THE LIST OF BOAT 2.ADD BOAT & DETAILS 3.PREVIOUS MANU 4.FOR SHOWING DETAILS";
cout<<" CHOSE YOUR OPTION::";
cin>>n4;
if(n4==1)
x.see_m();
else if(n4==2)
x.add_m();
else if(n4==3)
break;
else if(n4==4)
x.serch_m();
}
}
else if(n2==3)
break;
}//while ar bra
}//n1 ar bra
else if(n1==2)
{
while(1)
{
properti p;
clrscr();
int m;
cout<<" PROPERTI ****************";
cout<<" 1.SEE THE LIST OF PROPERTI 2.ADD PROPERTI &BOAT NAME 3.PREVIOUS MANU 4.SERCH THE PROPERTI 5.ADD BOAT NAME";
cout<<" CHOSE YOUR OPTION::";
cin>>m;
if(m==1)
p.see_p();
else if(m==2)
p.add_p();
else if(m==4)
p.serch_p();
else if(m==3)
break;
else if(m==5)
p.boat_p();
}
}
else
if(n1==3)
break;
}
}
/************************MAIN**********************/
int main()
{
textcolor(114);
textbackground(0);
highvideo();
f a;
return 0;
}
The program requires a text file to be created to get the output.
The sample text file is as follows:
DINGI.TXT Data :
It runs by humane.It is made of wood.
DISEL.TXT data :
lanch
LANCH.TXT Data :
Lanch runs by disel.Genarally it has one motor.
MENU_E.TXT Data :
steamer
lanch
MENU_M.TXT Data :
dingi
MENU_P.TXT Data :
Oil
Disel
OIL.TXT Data :
steamer
STEAMER.TXT Data :
It is most popular water vahicle.It runs by oil.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.