SlideShare a Scribd company logo
1 of 15
i want to add to this c++ code a condition so that you can only chose from - robbery,
violation,medical, fire- if the user enterd something else the program should ask him to
again chose from this service only... plz don't change the code alot just add .
#include <iostream>
#include <string>
#include <cstring>
#include <cstdlib>
#include <stdio.h>
#include <time.h>
using namespace std;
const int size = 5 ;
string services [size]= {"Robbery ", "Violation ", "Medical ","Fire "};//The menu
string search;
string Thesrevice;
struct Info {
string name;
int age;
string location;
string AdditionalNote;
};
void Ask(string &z){// Function for Searching in array
cout<< "n Your emergency?";
cout << endl;
cin>> z;
for (int i = 0 ; i< size ; i++){
if (services[i].find(z,0)!= string::npos){
cout<< "Your choice is "<< services[i]<<endl;
Thesrevice = services[i];
break;}
}}
void get_data(Info *array,int S){
cout<< "Enter Your name, age, location and any additional note"<<endl;
cin>> array[0].name>>array[1].age>>array[2].location>>
array[3].AdditionalNote;
}
int R(){
srand(time(0));
cout <<"n"<< "Your code: "<< rand();
}
int gethelp(){
srand(time(0));
return rand()%(10-5+1)+5;
}
int main(){
string temp[size];
string tem;
Info Array [5];
string answer;
string repla;
cout<< " 911 What's your emergency? n" ;
cout<< endl;
for(int i = 0; i<size ; i++){
cout<< services[i]<<"t";}
cout<< endl;
cout<< endl;
cout << "Enter your choice as word all small, ex: fire.n";
cout << "To repeate the menu in anoter order inter (other)n";
cout << "To sort the menu alphabetaically inter (abc) n";
Ask(search);
if (search == "other"){ // Shifting -right by 2
int NewIndex;
for (int i=0; i<size;i++)
{ NewIndex=i+2;
if(NewIndex >=size)
NewIndex=NewIndex % size;
temp [NewIndex]= services[i];
;}
cout<< "The new order:"<< endl;
for (int i =0; i<size; i++)
cout<< temp[i]<< "t";
Ask(search);
}
if (search == "abc"){//Sorting Alphabetically
for (int x = 0; x < size; x++) {
for (int y = x+1; y < size; y++) {
if (services[x]>services [y]){
tem=services [x];
services[x]=services[y];
services[y]=tem;}}}
cout << "nAlphabetical order of servisec :n";
for (int x = 0; x < size; x++)
cout << services[x] << "t";
cout << endl;
Ask(search);}
cout<<endl;
cout<<"___________________________________________________ n";
cout<<endl;
get_data(Array,5);// Calling Function to get data fron user
cout<<"Okay " << Array[0].name << " calm down, we will send you help n";
cout<<
"Your Name: "<<"t"<< Array[0].name << "n";
cout<<
"Your Age: "<<"t"<< Array[1].age << "n";
cout<<
"Your Location: "<<"t"<< Array[2].location << "n";
cout<<
"Additional Note: "<<"t"<< Array[3].AdditionalNote << "t";
cout<<"n"<<" Please enter 1 if your info are right or 2 if you need to modify";
cin>> answer;
if (answer == "2"){
string Qrep;
string Qrepp;
string rep;
int repp;
int replaa;
cout<<"Do you want to replace? Enter Y or N"<< endl; //Adding value
cin>> Qrep;
if(Qrep == "Y"){
cout << "Is it your age? Enter Y or N"<< endl;
cin >> Qrepp;
if (Qrepp == "Y"){
cout<< "Enter your real age please!"<< endl;
cin>> repp; }
Array[1].age=repp;
}if (Qrepp=="N"){ // Updating values
cout << "Enter your wrong answer ";
cin>> rep;
cout << "Write your replacementt:";
cin>> repla;
if(Array[0].name== rep)
Array[0].name=repla;
if(Array[2].location== rep)
Array[2].location=repla;
if(Array[3].AdditionalNote== rep)
Array[3].AdditionalNote= repla;
}
if (Qrep == "N"){
R();
}
}
cout<<"Okay " << Array[0].name << " Your updated data: n";
cout<<
"Your Name: "<<"t"<< Array[0].name << "n";
cout<<
"Your Age: "<<"t"<< Array[1].age << "n";
cout<<
"Your Location: "<<"t"<< Array[2].location << "n";
cout<<
"Additional Note: "<<"t"<< Array[3].AdditionalNote << "t"<<endl;
int random=gethelp();
cout<<"you will get help within:"<<random<<"mintues"<<endl;
R();
return 0;
}

More Related Content

Similar to i want to add to this c++ code a condition so that you can only chose.docx

Questions has 4 parts.1st part Program to implement sorting algor.pdf
Questions has 4 parts.1st part Program to implement sorting algor.pdfQuestions has 4 parts.1st part Program to implement sorting algor.pdf
Questions has 4 parts.1st part Program to implement sorting algor.pdfapexelectronices01
 
CBSE Class XII Comp sc practical file
CBSE Class XII Comp sc practical fileCBSE Class XII Comp sc practical file
CBSE Class XII Comp sc practical filePranav Ghildiyal
 
I have written the code but cannot complete the assignment please help.pdf
I have written the code but cannot complete the assignment please help.pdfI have written the code but cannot complete the assignment please help.pdf
I have written the code but cannot complete the assignment please help.pdfshreeaadithyaacellso
 
Implement the Queue ADT using array – based approach. Using C++ prog.pdf
Implement the Queue ADT using array – based approach. Using C++ prog.pdfImplement the Queue ADT using array – based approach. Using C++ prog.pdf
Implement the Queue ADT using array – based approach. Using C++ prog.pdfsktambifortune
 
CBSE Class XI Programming in C++
CBSE Class XI Programming in C++CBSE Class XI Programming in C++
CBSE Class XI Programming in C++Pranav Ghildiyal
 
Computer Science Practical Science C++ with SQL commands
Computer Science Practical Science C++ with SQL commandsComputer Science Practical Science C++ with SQL commands
Computer Science Practical Science C++ with SQL commandsVishvjeet Yadav
 
Cs pritical file
Cs pritical fileCs pritical file
Cs pritical fileMitul Patel
 
Sparse Matrix and Polynomial
Sparse Matrix and PolynomialSparse Matrix and Polynomial
Sparse Matrix and PolynomialAroosa Rajput
 
Please teach me how to fix the errors and where should be modified. .pdf
Please teach me how to fix the errors and where should be modified. .pdfPlease teach me how to fix the errors and where should be modified. .pdf
Please teach me how to fix the errors and where should be modified. .pdfamarndsons
 
Taming Distribution: Formal Protocols for Akka Typed
Taming Distribution: Formal Protocols for Akka TypedTaming Distribution: Formal Protocols for Akka Typed
Taming Distribution: Formal Protocols for Akka TypedRoland Kuhn
 
aming distribution: formal protocols for Akka Typed
aming distribution: formal protocols for Akka Typedaming distribution: formal protocols for Akka Typed
aming distribution: formal protocols for Akka TypedJ On The Beach
 

Similar to i want to add to this c++ code a condition so that you can only chose.docx (17)

Questions has 4 parts.1st part Program to implement sorting algor.pdf
Questions has 4 parts.1st part Program to implement sorting algor.pdfQuestions has 4 parts.1st part Program to implement sorting algor.pdf
Questions has 4 parts.1st part Program to implement sorting algor.pdf
 
CBSE Class XII Comp sc practical file
CBSE Class XII Comp sc practical fileCBSE Class XII Comp sc practical file
CBSE Class XII Comp sc practical file
 
project
projectproject
project
 
I have written the code but cannot complete the assignment please help.pdf
I have written the code but cannot complete the assignment please help.pdfI have written the code but cannot complete the assignment please help.pdf
I have written the code but cannot complete the assignment please help.pdf
 
Implement the Queue ADT using array – based approach. Using C++ prog.pdf
Implement the Queue ADT using array – based approach. Using C++ prog.pdfImplement the Queue ADT using array – based approach. Using C++ prog.pdf
Implement the Queue ADT using array – based approach. Using C++ prog.pdf
 
Arrays
ArraysArrays
Arrays
 
CBSE Class XI Programming in C++
CBSE Class XI Programming in C++CBSE Class XI Programming in C++
CBSE Class XI Programming in C++
 
Computer Science Practical Science C++ with SQL commands
Computer Science Practical Science C++ with SQL commandsComputer Science Practical Science C++ with SQL commands
Computer Science Practical Science C++ with SQL commands
 
Cpp c++ 1
Cpp c++ 1Cpp c++ 1
Cpp c++ 1
 
Cpp programs
Cpp programsCpp programs
Cpp programs
 
Cs pritical file
Cs pritical fileCs pritical file
Cs pritical file
 
Sparse Matrix and Polynomial
Sparse Matrix and PolynomialSparse Matrix and Polynomial
Sparse Matrix and Polynomial
 
DSC program.pdf
DSC program.pdfDSC program.pdf
DSC program.pdf
 
Please teach me how to fix the errors and where should be modified. .pdf
Please teach me how to fix the errors and where should be modified. .pdfPlease teach me how to fix the errors and where should be modified. .pdf
Please teach me how to fix the errors and where should be modified. .pdf
 
Railwaynew
RailwaynewRailwaynew
Railwaynew
 
Taming Distribution: Formal Protocols for Akka Typed
Taming Distribution: Formal Protocols for Akka TypedTaming Distribution: Formal Protocols for Akka Typed
Taming Distribution: Formal Protocols for Akka Typed
 
aming distribution: formal protocols for Akka Typed
aming distribution: formal protocols for Akka Typedaming distribution: formal protocols for Akka Typed
aming distribution: formal protocols for Akka Typed
 

More from hendriciraida

In a recent annual report and related Global Responsibiity Report- Sta.docx
In a recent annual report and related Global Responsibiity Report- Sta.docxIn a recent annual report and related Global Responsibiity Report- Sta.docx
In a recent annual report and related Global Responsibiity Report- Sta.docxhendriciraida
 
In a nutshell- Social Darwinism is employed by quasi-scientists and po.docx
In a nutshell- Social Darwinism is employed by quasi-scientists and po.docxIn a nutshell- Social Darwinism is employed by quasi-scientists and po.docx
In a nutshell- Social Darwinism is employed by quasi-scientists and po.docxhendriciraida
 
In a modern economy- who controls the creation of money- Who profits f.docx
In a modern economy- who controls the creation of money- Who profits f.docxIn a modern economy- who controls the creation of money- Who profits f.docx
In a modern economy- who controls the creation of money- Who profits f.docxhendriciraida
 
In a 1-1-5 page document (APA format- 12-point font- double-spaced) an.docx
In a 1-1-5 page document (APA format- 12-point font- double-spaced) an.docxIn a 1-1-5 page document (APA format- 12-point font- double-spaced) an.docx
In a 1-1-5 page document (APA format- 12-point font- double-spaced) an.docxhendriciraida
 
In 2017 in the economy of Cortania- Consumption was $1500-00- Investme.docx
In 2017 in the economy of Cortania- Consumption was $1500-00- Investme.docxIn 2017 in the economy of Cortania- Consumption was $1500-00- Investme.docx
In 2017 in the economy of Cortania- Consumption was $1500-00- Investme.docxhendriciraida
 
In 1868- the accidental introduction into the United States of the cot.docx
In 1868- the accidental introduction into the United States of the cot.docxIn 1868- the accidental introduction into the United States of the cot.docx
In 1868- the accidental introduction into the United States of the cot.docxhendriciraida
 
In 1950 the average year of education was 8 years- The standard deviat.docx
In 1950 the average year of education was 8 years- The standard deviat.docxIn 1950 the average year of education was 8 years- The standard deviat.docx
In 1950 the average year of education was 8 years- The standard deviat.docxhendriciraida
 
Important- Python Program- No imports- Use Custom Functions if necessa.docx
Important- Python Program- No imports- Use Custom Functions if necessa.docxImportant- Python Program- No imports- Use Custom Functions if necessa.docx
Important- Python Program- No imports- Use Custom Functions if necessa.docxhendriciraida
 
import java-io-IOException- import java-nio-file-Files- import java-ni.docx
import java-io-IOException- import java-nio-file-Files- import java-ni.docximport java-io-IOException- import java-nio-file-Files- import java-ni.docx
import java-io-IOException- import java-nio-file-Files- import java-ni.docxhendriciraida
 
Impact on Taxes- You have a marginal tax rate of 22-- You suddenly rea.docx
Impact on Taxes- You have a marginal tax rate of 22-- You suddenly rea.docxImpact on Taxes- You have a marginal tax rate of 22-- You suddenly rea.docx
Impact on Taxes- You have a marginal tax rate of 22-- You suddenly rea.docxhendriciraida
 
Immune complex is formed when antigen and antibody bind- Formation of.docx
Immune complex is formed when antigen and antibody bind- Formation of.docxImmune complex is formed when antigen and antibody bind- Formation of.docx
Immune complex is formed when antigen and antibody bind- Formation of.docxhendriciraida
 
Imani and Doug were divorced on December 31-2022 - after 10 years of m.docx
Imani and Doug were divorced on December 31-2022 - after 10 years of m.docxImani and Doug were divorced on December 31-2022 - after 10 years of m.docx
Imani and Doug were divorced on December 31-2022 - after 10 years of m.docxhendriciraida
 
Iloginning rav materiala invantoing siding favimaceriala inventory Dif.docx
Iloginning rav materiala invantoing siding favimaceriala inventory Dif.docxIloginning rav materiala invantoing siding favimaceriala inventory Dif.docx
Iloginning rav materiala invantoing siding favimaceriala inventory Dif.docxhendriciraida
 
ii) the 16000$ restumping fee iii- Ihe $2000 tor the new hot water sys.docx
ii) the 16000$ restumping fee iii- Ihe $2000 tor the new hot water sys.docxii) the 16000$ restumping fee iii- Ihe $2000 tor the new hot water sys.docx
ii) the 16000$ restumping fee iii- Ihe $2000 tor the new hot water sys.docxhendriciraida
 
If you were living in Galveston at the time- how could you have used y.docx
If you were living in Galveston at the time- how could you have used y.docxIf you were living in Galveston at the time- how could you have used y.docx
If you were living in Galveston at the time- how could you have used y.docxhendriciraida
 
If the share price of Nostos- a New York-based shipping firm- rises fr.docx
If the share price of Nostos- a New York-based shipping firm- rises fr.docxIf the share price of Nostos- a New York-based shipping firm- rises fr.docx
If the share price of Nostos- a New York-based shipping firm- rises fr.docxhendriciraida
 
If the mean annual return for common stocks is 11-0- and the standard.docx
If the mean annual return for common stocks is 11-0- and the standard.docxIf the mean annual return for common stocks is 11-0- and the standard.docx
If the mean annual return for common stocks is 11-0- and the standard.docxhendriciraida
 
If NADH donates a pair of electrons to the mitochondrial electron tran.docx
If NADH donates a pair of electrons to the mitochondrial electron tran.docxIf NADH donates a pair of electrons to the mitochondrial electron tran.docx
If NADH donates a pair of electrons to the mitochondrial electron tran.docxhendriciraida
 
If Molly's pension plan from Retirement Management Services included a.docx
If Molly's pension plan from Retirement Management Services included a.docxIf Molly's pension plan from Retirement Management Services included a.docx
If Molly's pension plan from Retirement Management Services included a.docxhendriciraida
 
If a varlable Y supersedes a variable X- then X must be influencing Y.docx
If a varlable Y supersedes a variable X- then X must be influencing Y.docxIf a varlable Y supersedes a variable X- then X must be influencing Y.docx
If a varlable Y supersedes a variable X- then X must be influencing Y.docxhendriciraida
 

More from hendriciraida (20)

In a recent annual report and related Global Responsibiity Report- Sta.docx
In a recent annual report and related Global Responsibiity Report- Sta.docxIn a recent annual report and related Global Responsibiity Report- Sta.docx
In a recent annual report and related Global Responsibiity Report- Sta.docx
 
In a nutshell- Social Darwinism is employed by quasi-scientists and po.docx
In a nutshell- Social Darwinism is employed by quasi-scientists and po.docxIn a nutshell- Social Darwinism is employed by quasi-scientists and po.docx
In a nutshell- Social Darwinism is employed by quasi-scientists and po.docx
 
In a modern economy- who controls the creation of money- Who profits f.docx
In a modern economy- who controls the creation of money- Who profits f.docxIn a modern economy- who controls the creation of money- Who profits f.docx
In a modern economy- who controls the creation of money- Who profits f.docx
 
In a 1-1-5 page document (APA format- 12-point font- double-spaced) an.docx
In a 1-1-5 page document (APA format- 12-point font- double-spaced) an.docxIn a 1-1-5 page document (APA format- 12-point font- double-spaced) an.docx
In a 1-1-5 page document (APA format- 12-point font- double-spaced) an.docx
 
In 2017 in the economy of Cortania- Consumption was $1500-00- Investme.docx
In 2017 in the economy of Cortania- Consumption was $1500-00- Investme.docxIn 2017 in the economy of Cortania- Consumption was $1500-00- Investme.docx
In 2017 in the economy of Cortania- Consumption was $1500-00- Investme.docx
 
In 1868- the accidental introduction into the United States of the cot.docx
In 1868- the accidental introduction into the United States of the cot.docxIn 1868- the accidental introduction into the United States of the cot.docx
In 1868- the accidental introduction into the United States of the cot.docx
 
In 1950 the average year of education was 8 years- The standard deviat.docx
In 1950 the average year of education was 8 years- The standard deviat.docxIn 1950 the average year of education was 8 years- The standard deviat.docx
In 1950 the average year of education was 8 years- The standard deviat.docx
 
Important- Python Program- No imports- Use Custom Functions if necessa.docx
Important- Python Program- No imports- Use Custom Functions if necessa.docxImportant- Python Program- No imports- Use Custom Functions if necessa.docx
Important- Python Program- No imports- Use Custom Functions if necessa.docx
 
import java-io-IOException- import java-nio-file-Files- import java-ni.docx
import java-io-IOException- import java-nio-file-Files- import java-ni.docximport java-io-IOException- import java-nio-file-Files- import java-ni.docx
import java-io-IOException- import java-nio-file-Files- import java-ni.docx
 
Impact on Taxes- You have a marginal tax rate of 22-- You suddenly rea.docx
Impact on Taxes- You have a marginal tax rate of 22-- You suddenly rea.docxImpact on Taxes- You have a marginal tax rate of 22-- You suddenly rea.docx
Impact on Taxes- You have a marginal tax rate of 22-- You suddenly rea.docx
 
Immune complex is formed when antigen and antibody bind- Formation of.docx
Immune complex is formed when antigen and antibody bind- Formation of.docxImmune complex is formed when antigen and antibody bind- Formation of.docx
Immune complex is formed when antigen and antibody bind- Formation of.docx
 
Imani and Doug were divorced on December 31-2022 - after 10 years of m.docx
Imani and Doug were divorced on December 31-2022 - after 10 years of m.docxImani and Doug were divorced on December 31-2022 - after 10 years of m.docx
Imani and Doug were divorced on December 31-2022 - after 10 years of m.docx
 
Iloginning rav materiala invantoing siding favimaceriala inventory Dif.docx
Iloginning rav materiala invantoing siding favimaceriala inventory Dif.docxIloginning rav materiala invantoing siding favimaceriala inventory Dif.docx
Iloginning rav materiala invantoing siding favimaceriala inventory Dif.docx
 
ii) the 16000$ restumping fee iii- Ihe $2000 tor the new hot water sys.docx
ii) the 16000$ restumping fee iii- Ihe $2000 tor the new hot water sys.docxii) the 16000$ restumping fee iii- Ihe $2000 tor the new hot water sys.docx
ii) the 16000$ restumping fee iii- Ihe $2000 tor the new hot water sys.docx
 
If you were living in Galveston at the time- how could you have used y.docx
If you were living in Galveston at the time- how could you have used y.docxIf you were living in Galveston at the time- how could you have used y.docx
If you were living in Galveston at the time- how could you have used y.docx
 
If the share price of Nostos- a New York-based shipping firm- rises fr.docx
If the share price of Nostos- a New York-based shipping firm- rises fr.docxIf the share price of Nostos- a New York-based shipping firm- rises fr.docx
If the share price of Nostos- a New York-based shipping firm- rises fr.docx
 
If the mean annual return for common stocks is 11-0- and the standard.docx
If the mean annual return for common stocks is 11-0- and the standard.docxIf the mean annual return for common stocks is 11-0- and the standard.docx
If the mean annual return for common stocks is 11-0- and the standard.docx
 
If NADH donates a pair of electrons to the mitochondrial electron tran.docx
If NADH donates a pair of electrons to the mitochondrial electron tran.docxIf NADH donates a pair of electrons to the mitochondrial electron tran.docx
If NADH donates a pair of electrons to the mitochondrial electron tran.docx
 
If Molly's pension plan from Retirement Management Services included a.docx
If Molly's pension plan from Retirement Management Services included a.docxIf Molly's pension plan from Retirement Management Services included a.docx
If Molly's pension plan from Retirement Management Services included a.docx
 
If a varlable Y supersedes a variable X- then X must be influencing Y.docx
If a varlable Y supersedes a variable X- then X must be influencing Y.docxIf a varlable Y supersedes a variable X- then X must be influencing Y.docx
If a varlable Y supersedes a variable X- then X must be influencing Y.docx
 

Recently uploaded

24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...Nguyen Thanh Tu Collection
 
Graduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptxGraduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptxneillewis46
 
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUMDEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUMELOISARIVERA8
 
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽中 央社
 
The Story of Village Palampur Class 9 Free Study Material PDF
The Story of Village Palampur Class 9 Free Study Material PDFThe Story of Village Palampur Class 9 Free Study Material PDF
The Story of Village Palampur Class 9 Free Study Material PDFVivekanand Anglo Vedic Academy
 
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjjStl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjjMohammed Sikander
 
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文中 央社
 
Basic Civil Engineering notes on Transportation Engineering & Modes of Transport
Basic Civil Engineering notes on Transportation Engineering & Modes of TransportBasic Civil Engineering notes on Transportation Engineering & Modes of Transport
Basic Civil Engineering notes on Transportation Engineering & Modes of TransportDenish Jangid
 
Spring gala 2024 photo slideshow - Celebrating School-Community Partnerships
Spring gala 2024 photo slideshow - Celebrating School-Community PartnershipsSpring gala 2024 photo slideshow - Celebrating School-Community Partnerships
Spring gala 2024 photo slideshow - Celebrating School-Community Partnershipsexpandedwebsite
 
Trauma-Informed Leadership - Five Practical Principles
Trauma-Informed Leadership - Five Practical PrinciplesTrauma-Informed Leadership - Five Practical Principles
Trauma-Informed Leadership - Five Practical PrinciplesPooky Knightsmith
 
8 Tips for Effective Working Capital Management
8 Tips for Effective Working Capital Management8 Tips for Effective Working Capital Management
8 Tips for Effective Working Capital ManagementMBA Assignment Experts
 
An Overview of the Odoo 17 Knowledge App
An Overview of the Odoo 17 Knowledge AppAn Overview of the Odoo 17 Knowledge App
An Overview of the Odoo 17 Knowledge AppCeline George
 
How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17Celine George
 
Improved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio AppImproved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio AppCeline George
 
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading RoomSternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading RoomSean M. Fox
 
e-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopale-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi RajagopalEADTU
 
Đề tieng anh thpt 2024 danh cho cac ban hoc sinh
Đề tieng anh thpt 2024 danh cho cac ban hoc sinhĐề tieng anh thpt 2024 danh cho cac ban hoc sinh
Đề tieng anh thpt 2024 danh cho cac ban hoc sinhleson0603
 
An overview of the various scriptures in Hinduism
An overview of the various scriptures in HinduismAn overview of the various scriptures in Hinduism
An overview of the various scriptures in HinduismDabee Kamal
 

Recently uploaded (20)

24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
 
Graduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptxGraduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptx
 
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUMDEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
 
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
 
ESSENTIAL of (CS/IT/IS) class 07 (Networks)
ESSENTIAL of (CS/IT/IS) class 07 (Networks)ESSENTIAL of (CS/IT/IS) class 07 (Networks)
ESSENTIAL of (CS/IT/IS) class 07 (Networks)
 
The Story of Village Palampur Class 9 Free Study Material PDF
The Story of Village Palampur Class 9 Free Study Material PDFThe Story of Village Palampur Class 9 Free Study Material PDF
The Story of Village Palampur Class 9 Free Study Material PDF
 
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjjStl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
 
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
 
Basic Civil Engineering notes on Transportation Engineering & Modes of Transport
Basic Civil Engineering notes on Transportation Engineering & Modes of TransportBasic Civil Engineering notes on Transportation Engineering & Modes of Transport
Basic Civil Engineering notes on Transportation Engineering & Modes of Transport
 
Spring gala 2024 photo slideshow - Celebrating School-Community Partnerships
Spring gala 2024 photo slideshow - Celebrating School-Community PartnershipsSpring gala 2024 photo slideshow - Celebrating School-Community Partnerships
Spring gala 2024 photo slideshow - Celebrating School-Community Partnerships
 
Trauma-Informed Leadership - Five Practical Principles
Trauma-Informed Leadership - Five Practical PrinciplesTrauma-Informed Leadership - Five Practical Principles
Trauma-Informed Leadership - Five Practical Principles
 
8 Tips for Effective Working Capital Management
8 Tips for Effective Working Capital Management8 Tips for Effective Working Capital Management
8 Tips for Effective Working Capital Management
 
An Overview of the Odoo 17 Knowledge App
An Overview of the Odoo 17 Knowledge AppAn Overview of the Odoo 17 Knowledge App
An Overview of the Odoo 17 Knowledge App
 
How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17
 
Improved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio AppImproved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio App
 
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading RoomSternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
 
e-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopale-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopal
 
Đề tieng anh thpt 2024 danh cho cac ban hoc sinh
Đề tieng anh thpt 2024 danh cho cac ban hoc sinhĐề tieng anh thpt 2024 danh cho cac ban hoc sinh
Đề tieng anh thpt 2024 danh cho cac ban hoc sinh
 
Mattingly "AI and Prompt Design: LLMs with NER"
Mattingly "AI and Prompt Design: LLMs with NER"Mattingly "AI and Prompt Design: LLMs with NER"
Mattingly "AI and Prompt Design: LLMs with NER"
 
An overview of the various scriptures in Hinduism
An overview of the various scriptures in HinduismAn overview of the various scriptures in Hinduism
An overview of the various scriptures in Hinduism
 

i want to add to this c++ code a condition so that you can only chose.docx

  • 1. i want to add to this c++ code a condition so that you can only chose from - robbery, violation,medical, fire- if the user enterd something else the program should ask him to again chose from this service only... plz don't change the code alot just add . #include <iostream> #include <string> #include <cstring> #include <cstdlib> #include <stdio.h> #include <time.h> using namespace std; const int size = 5 ; string services [size]= {"Robbery ", "Violation ", "Medical ","Fire "};//The menu string search; string Thesrevice; struct Info { string name; int age;
  • 2. string location; string AdditionalNote; }; void Ask(string &z){// Function for Searching in array cout<< "n Your emergency?"; cout << endl; cin>> z; for (int i = 0 ; i< size ; i++){ if (services[i].find(z,0)!= string::npos){ cout<< "Your choice is "<< services[i]<<endl;
  • 3. Thesrevice = services[i]; break;} }} void get_data(Info *array,int S){ cout<< "Enter Your name, age, location and any additional note"<<endl; cin>> array[0].name>>array[1].age>>array[2].location>> array[3].AdditionalNote; } int R(){ srand(time(0));
  • 4. cout <<"n"<< "Your code: "<< rand(); } int gethelp(){ srand(time(0)); return rand()%(10-5+1)+5; } int main(){ string temp[size]; string tem; Info Array [5]; string answer; string repla; cout<< " 911 What's your emergency? n" ; cout<< endl;
  • 5. for(int i = 0; i<size ; i++){ cout<< services[i]<<"t";} cout<< endl; cout<< endl; cout << "Enter your choice as word all small, ex: fire.n"; cout << "To repeate the menu in anoter order inter (other)n"; cout << "To sort the menu alphabetaically inter (abc) n"; Ask(search); if (search == "other"){ // Shifting -right by 2 int NewIndex; for (int i=0; i<size;i++)
  • 6. { NewIndex=i+2; if(NewIndex >=size) NewIndex=NewIndex % size; temp [NewIndex]= services[i]; ;} cout<< "The new order:"<< endl; for (int i =0; i<size; i++) cout<< temp[i]<< "t"; Ask(search); }
  • 7. if (search == "abc"){//Sorting Alphabetically for (int x = 0; x < size; x++) { for (int y = x+1; y < size; y++) { if (services[x]>services [y]){ tem=services [x]; services[x]=services[y]; services[y]=tem;}}} cout << "nAlphabetical order of servisec :n"; for (int x = 0; x < size; x++) cout << services[x] << "t"; cout << endl;
  • 8. Ask(search);} cout<<endl; cout<<"___________________________________________________ n"; cout<<endl; get_data(Array,5);// Calling Function to get data fron user cout<<"Okay " << Array[0].name << " calm down, we will send you help n"; cout<< "Your Name: "<<"t"<< Array[0].name << "n"; cout<< "Your Age: "<<"t"<< Array[1].age << "n"; cout<< "Your Location: "<<"t"<< Array[2].location << "n"; cout<< "Additional Note: "<<"t"<< Array[3].AdditionalNote << "t"; cout<<"n"<<" Please enter 1 if your info are right or 2 if you need to modify";
  • 9. cin>> answer; if (answer == "2"){ string Qrep; string Qrepp; string rep; int repp; int replaa; cout<<"Do you want to replace? Enter Y or N"<< endl; //Adding value cin>> Qrep; if(Qrep == "Y"){
  • 10. cout << "Is it your age? Enter Y or N"<< endl; cin >> Qrepp; if (Qrepp == "Y"){ cout<< "Enter your real age please!"<< endl; cin>> repp; }
  • 11. Array[1].age=repp; }if (Qrepp=="N"){ // Updating values cout << "Enter your wrong answer "; cin>> rep;
  • 12. cout << "Write your replacementt:"; cin>> repla; if(Array[0].name== rep) Array[0].name=repla;
  • 14. } if (Qrep == "N"){ R(); } } cout<<"Okay " << Array[0].name << " Your updated data: n"; cout<< "Your Name: "<<"t"<< Array[0].name << "n";
  • 15. cout<< "Your Age: "<<"t"<< Array[1].age << "n"; cout<< "Your Location: "<<"t"<< Array[2].location << "n"; cout<< "Additional Note: "<<"t"<< Array[3].AdditionalNote << "t"<<endl; int random=gethelp(); cout<<"you will get help within:"<<random<<"mintues"<<endl; R(); return 0; }