473,416 Members | 1,924 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,416 software developers and data experts.

C++--- my program runs well but brings an error on the output when i try to put the transmission, what is wrong with my program?

#include<iostream>

#include<cstring>

#include<cstdlib>

#include<iomanip>

#include<windows.h>

//#include <ctime>

//#include <dos.h>

#include<dos.h>

#include<conio.h>

#include<cstdio>

#define max 3

using namespace std;
struct Car

{

long int Code;
char Make[10];
char Model[10];
int Year;
long int Price;
bool Transmission;

};

int num;

Car c[max],tcc[max];

enum Transmission{ F, T };

int main()

{

{
boolean Transmission1, Transmission2;
Transmission1 = F;

if (Transmission1 == F) {
printf("Auto is true\n");
}
else {
printf("Auto is false\n");
}
Transmission2 = T;
if (Transmission2 == F) {
printf("Manual is false\n");
}
else {
printf("Manual is true\n");
}
}

system("cls");

void build();

void list();

void insert();

void deletes();

void edit();

void search();

char option;

void menu();

menu();

while((option=cin.get())!='7')

{

switch(option)

{

case '1':

build();

break;

case '2':

list();

break;

case '3':

insert();

break;

case '4':

deletes();

break;

case '5':

edit();

break;

case '6':

search();

break;

}

menu();

}

return 0;

}

void menu()

{

system("cls");

// highvideo();

cout<<" ";

printf("\n***** Mini Database for Cars ***** ");



//normvideo();

cout<<endl;

cout<<" ";

cout<<"\n\t\t Press 1---->Build The Car Database ";

cout<<" ";

cout<<"\n\t\t Press 2---->List The Car Details ";

cout<<" ";

cout<<"\n\t\t Press 3---->Insert New Record ";

cout<<" ";

cout<<"\n\t\t Press 4---->Delete a Record ";

cout<<" ";

cout<<"\n\t\t Press 5---->Modify a Record ";

cout<<" ";

cout<<"\n\t\t Press 6---->Search a Record ";

cout<<" ";

cout<<"\n\t\t Press 7---->Quit Program ";

cout<<" ";

cout<<"\n\n \t\t Select Your Option Please ====> ";

}


void build()

{


system("cls");

// highvideo();

printf("Build The Database");

cout<<endl;

//highvideo();

cout<<"maximum number of entries ----- > 3"<<endl;

cout<<"Enter The Following Items"<<endl;

for(int i=0;i<=num-1;i++)

{

cout<<" Code ";

cin>>c[i].Code;

cout<<"Make ";

cin>>c[i].Make;

cout<<"Model ";

cin>>c[i].Model;

cout<<"Year ";

cin>>c[i].Year;

cout<<"Price ";

cin>>c[i].Price;

cout<<"Transmission ";

cin>>c[i].Transmission;

}

cout<<"going to main menu";

Sleep(2500);

}


void list()

{

system("cls");

// highvideo();

printf(" ********List The Details********");

cout<<endl;

//normvideo();

cout<<" Code Make Model Year Price Transmission(A/M)"<<endl;

cout<<" --------------------------------------------------------------------------------------"<<endl;

for(int i=0;i<=num-1;i++)

{

cout<<setw(6)<<c[i].Code;

cout<<setw(15)<<c[i].Make;

cout<<setw(15)<<c[i].Model;

cout<<setw(15)<<c[i].Year;

cout<<setw(15)<<c[i].Price;

cout<<setw(15)<<c[i].Transmission;

cout<<endl;

}

cout<<"going to main menu";

getch();

}

void insert()

{

system("cls");

int i=num;

num+=1;

// highvideo();

printf("Insert New Record");

cout<<endl;

//normvideo();

cout<<"Enter The Following Items"<<endl;

cout<<"Code ";

cin>>c[i].Code;

cout<<"Make ";

cin>>c[i].Make;

cout<<"Model ";

cin>>c[i].Model;

cout<<"Year ";

cin>>c[i].Year;

cout<<"Price ";

cin>>c[i].Price;

cout<<"Transmission ";

cin>>c[i].Transmission;

cout<<endl<<endl;

cout<<"going to main menu";

Sleep(500);


}



void deletes()

{

system("cls");

// highvideo();

int code;

int check;

printf("Delete a Record");

//normvideo();

cout<<endl;

cout<<"Enter An CarCode To Delete That Entry ";

cin>>code;

int i;

for(i=0;i<=num-1;i++)

{

if(c[i].Code==code)

{

check=i;

}

}

for(i=0;i<=num-1;i++)

{

if(i==check)

{

continue;

}

else

{

if(i>check)

{

tcc[i-1]=c[i];

}

else

{

tcc[i]=c[i];

}

}

}

num--;


for(i=0;i<=num-1;i++)

{

c[i]=tcc[i];

}

}


void edit()

{

system("cls");

int carcode;

// highvideo();

printf(" Update a Record ");

cout<<endl;

cout<<endl;

int i;

void editmenu();

void editcode(int);

void editmake(int);

void editmodel(int);

void edityear(int);

void editprice(int);

void edittransmission(int);

char option;

//normvideo();

cout<<"Enter An carcode To Update a Record---- ";

cin>>carcode;

editmenu();

for(i=0;i<=num-1;i++)

{

if(c[i].Code==carcode)

{


while((option=cin.get())!='8')

{

switch(option)

{

case 'c':

editcode(i);

break;

case 'm':

editmake(i);

break;

case 'n':

editmodel(i);

break;

case 'y':

edityear(i);

break;

case 'p':

editprice(i);

break;

}

editmenu();

}

}

}

}

void editmenu()

{

system("cls");

cout<<" What Do You Want To edit";

cout<<" c--------->Code ";

cout<<" m--------->Make ";

cout<<" n--------->Model";

cout<<" y--------->Year ";

cout<<" p--------->Price ";

cout<<" t--------->Transmission";

cout<<" 7--------->QUIT ";

cout<<" Options Please ---->>> ";

}

void editcode(int i)

{

cout<<"Enter New Code-----> ";

cin>>c[i].Code;

}

void editmake(int i)

{

cout<<"Enter New Make-----> ";

cin>>c[i].Make;

}

void editmodel(int i)

{

cout<<"enter new Model-----> ";

cin>>c[i].Model;

}

void edityear(int i)

{

cout<<"Enter new Year";

cin>>c[i].Year;

}

void editprice(int i)

{

cout<<"Enter new Price ";

cin>>c[i].Price;

}

void edittransmission(int i)

{

cout<<"Enter new Transmission ";

cin>>c[i].Transmission;

}


void search()

{

system("cls");

// highvideo();

printf("Welcome To Search Of Car Database ");

//normvideo();

cout<<endl;

cout<<endl;

int carcode;

cout<<"You Can Search Only By code Of a car";

cout<<"Enter Code Of a Car ";

cin>>carcode;

for(int i=0;i<=num-1;i++)

{

if(c[i].Code==carcode)

{


cout<<" Code Make Model Year Price Transmission(A/M) "<<endl;

cout<<" -----------------------------------------------------------------------------------------"<<endl;

cout<<setw(6)<<c[i].Code;

cout<<setw(15)<<c[i].Make;

cout<<setw(15)<<c[i].Model;

cout<<setw(15)<<c[i].Year;

cout<<setw(15)<<c[i].Price;

cout<<setw(15)<<c[i].Transmission;

cout<<endl;

}


}

cout<<"going to main menu";

getch();



}
Aug 14 '22 #1
0 1981

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Ollie | last post by:
I am trying to figure out how a complex program written in python works. I am new to python so looking at the source code directly is not helping me much. As such, I am running the program under...
10
by: jeff regoord | last post by:
A user inputs a float value. The scanf() function gets the value. However, I need to create an error handler with an if else statement saying invalid input if the input is not a number. Does...
0
by: Jordi | last post by:
I'm making a feature-file to train a Neural Network, but now that I've added a new feature, the output becomes corrupted. The output is as follows: 3000 25 1_002858 5 0 0 0 0 2 2 0 0 0 0 2 2 0 0...
7
by: Nena | last post by:
Hi there, I'm trying to include the Numerical Recipes for C++ for the Dev-C++ Editor Version. But so far I've failed. Therefore I've copied all head-files (for example nr.h) into the folder...
6
by: André | last post by:
Hi, I made a webform for a survey, with multiple-choice questions. The results of each question is put into a table e.g.: values frequency 1 6 2 3 3 32 4 ...
4
by: Al Santino | last post by:
Hello, I've created a simple C# web services project using Visual Studio 2005. My service compiles and runs correctly when called by remote clients. I'm able to step through the service in the...
6
by: Theo v. Werkhoven | last post by:
Goodday, Something strange going on here. A piece of code I wrote bombs out in one of de directories under $HOME, but not in others. Here's a snipped: #v+ def bin2asc(c): s=''
8
by: Jothishankar | last post by:
Hi, I am new to c#. I am trying to build an application that does backup of files to an external hard disk. My application behaves strangely. When i run the application under debug mode (F5),...
4
by: comtrendz | last post by:
Application fails with error: 80040154 when attempting to open a doc in Word 2010. I have a VB.Net app that uses word to open documents. I am running VS 2008 on my PC with Office 2003. When I...
0
by: ecorbett | last post by:
I have a threaded C program that I want to launch using a Python GUI in a Unix environment. I want to be able to change the state of the GUI by gathering output from the C program. For instance,...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.