SlideShare a Scribd company logo
PLEASE HELP IN C++
For this test, you will need to create the following function. First add the function prototype to
person.h, then put the function implementation in person.cpp and finally invoke/test the function
in main.cpp. Please label your output clearly. E.g. After adding a person, the list is:
Create a function to read a persons information and insert into the list at a given position. The
function returns true if the insertion is successful and it returns false if the array is out of
capacity.
bool addPerson(PersonType list[], int &count);
Sample code in person.cpp
PersonType aPerson;
//read in person name, person citizenship, and age and populate aPerson
//e.g strcpy(aPerson.name, tempName)
//read position to insert inside the function - see sample //run
//position could be read from the user or you could set a //number that is not more than count. If
you read from the //user, check to make sure position is not > than count.
//shift and insert aPerson in the right position
Sample test code in main.cpp
if(addPerson(list, count) == true)
{output list}
You must be able to read cstrings with spaces.
You must not replace any existing values in the list. You must shift and insert in the right
position. See zybooks Lab 11.9 for reference.
You must be able to add at the beginning of the list and at the end - if your list has 4 elements,
users must be able to insert at position 0 through 4.
See Sample Runs below and test your code multiple times adding users at the beginning and at
the end.
You must make sure the position is within count.
You must check for unreasonable age (for example: age < 1 and age > 100 can be unreasonable).
Include a welcome and goodbye message. (See sample run below).
Must use all the given function prototypes under Task exactly as is. Function Prototypes and
implementations must be written in the appropriate files.
Do not add header comments for this exam, but you must have function comments for the
function you are writing.
Do not use containers of any sort or any vectors for this program. Use only the concepts we have
learned so far.
Criteria for Success
Test your program using the following sample runs, making sure you get the same output when
using the given inputs (in blue):
Welcome to my Citizens Database.
Here is your list so far:
Gayathri;USA;22
Stephanie;USA;27
Priya;India;34
Ahmed;Nigeria;52
Enter your name:
Navid
Enter your citizenship:
Ecuador
Enter your age:
34
Enter position number:
2
After adding a person, the list is:
Gayathri;USA;22
Stephanie;USA;27
Navid;Ecuador;34
Priya;India;34
Ahmed;Nigeria;52
Thank you for using my Citizen Database!!
Welcome to my Citizens Database.
Here is your list so far:
Gayathri;USA;22
Stephanie;USA;27
Priya;India;34
Ahmed;Nigeria;52
Enter your name:
Navid
Enter your citizenship:
Ecuador
Enter your age:
34
Enter position number:
9
Error! Invalid position.
Thank you for using my Citizen Database!!
Welcome to my Citizens Database.
Here is your list so far:
Gayathri;USA;22
Stephanie;USA;27
Priya;India;34
Ahmed;Nigeria;52
Enter your name:
Lucy
Enter your citizenship:
Ecuador
Enter your age:
34
Enter position number:
0
After adding a person, the list is:
Lucy;Ecuador;34
Gayathri;USA;22
Stephanie;USA;27
Priya;India;34
Ahmed;Nigeria;52
Thank you for using my Citizen Database!!
Welcome to my Citizens Database.
Here is your list so far:
Gayathri;USA;22
Stephanie;USA;27
Priya;India;34
Ahmed;Nigeria;52
Enter your name:
Arely
Enter your citizenship:
Mexico
Enter your age:
45
Enter position number:
4
After adding a person, the list is:
Gayathri;USA;22
Stephanie;USA;27
Priya;India;34
Ahmed;Nigeria;52
Arely;Mexico;45
Thank you for using my Citizen Database!!
You must be able to read cstrings with spaces.
You must not replace any existing values in the list. You must shift and insert in the right
position. See zybooks Lab 11.9 for reference.
You must be able to add at the beginning of the list and at the end - if your list has 4 elements,
users must be able to insert at position 0 through 4.
See Sample Runs below and test your code multiple times adding users at the beginning and at
the end.
You must make sure the position is within count.
You must check for unreasonable age (for example: age < 1 and age > 100 can be unreasonable).
Include a welcome and goodbye message. (See sample run).
Must use all the given function prototypes under Task exactly as is. Function Prototypes and
implementations must be written in the appropriate files.
Do not add header comments for this exam, but you must have function comments for the
function you are writing.
Do not use containers of any sort or any vectors for this program. Use only the concepts we have
learned so far.
THIS IS THE CODE PROVIDED
MAIN.CPP
//main driver file
//add header comments here.
#include "person.h"
const int CAPACITY = 20;
//function protoypes
//main and then functions.
int main()
{
PersonType list[CAPACITY];
int count = 0;
char fileName[] = "persons.txt";
populatePersons(list, count, fileName);
printPersons(list, count);
//call your functions here to do what is required.
return 0;
}
PERSON.CPP
//function to print list
void printPersons(const PersonType list[], int count)
{
cout << "List of citizen database!" << endl;
for(int index = 0; index < count; index++)
{
cout << list[index].name << ";" << list[index].citizenship;
cout << ";" << list[index].age << endl;
}
}
//add your function here for removePersons.....)
void setName(string name_input);
void setGpa(float gpa_input);
void setEnrollYear(int enrollYear_input);
void setRollNumber(int rollNumber_input);
void displayStudent();
string getName();
float getGpa();
int getEnrollYear();
int getRollNumber();
};
PERSON.H
//struct for PersonType
#pragma once
#include
#include
#include
using namespace std;
const int MAX_CHAR = 101;
struct PersonType
{
char name[MAX_CHAR];
char citizenship[MAX_CHAR];
int age;
};
//function prototypes
void populatePersons(PersonType list[], int& count, const char fileName[]);
void printPersons(const PersonType list[], int count);
//add your function prototype here.
PERSON.TXT
Gayathri USA 22
Stephanie USA 27
Priya India 34
Ahmed Nigeria 52
Welcome to my Citizens Database.
Here is your list so far:
Gayathri;USA;22
Stephanie;USA;27
Priya;India;34
Ahmed;Nigeria;52
Enter your name:
Navid
Enter your citizenship:
Ecuador
Enter your age:
34
Enter position number:
2
After adding a person, the list is:
Gayathri;USA;22
Stephanie;USA;27
Navid;Ecuador;34
Priya;India;34
Ahmed;Nigeria;52
Thank you for using my Citizen Database!!
Welcome to my Citizens Database.
Here is your list so far:
Gayathri;USA;22
Stephanie;USA;27
Priya;India;34
Ahmed;Nigeria;52
Enter your name:
Navid
Enter your citizenship:
Ecuador
Enter your age:
34
Enter position number:
9
Error! Invalid position.
Thank you for using my Citizen Database!!
Welcome to my Citizens Database.
Here is your list so far:
Gayathri;USA;22
Stephanie;USA;27
Priya;India;34
Ahmed;Nigeria;52
Enter your name:
Lucy
Enter your citizenship:
Ecuador
Enter your age:
34
Enter position number:
0
After adding a person, the list is:
Lucy;Ecuador;34
Gayathri;USA;22
Stephanie;USA;27
Priya;India;34
Ahmed;Nigeria;52
Thank you for using my Citizen Database!!
Welcome to my Citizens Database.
Here is your list so far:
Gayathri;USA;22
Stephanie;USA;27
Priya;India;34
Ahmed;Nigeria;52
Enter your name:
Arely
Enter your citizenship:
Mexico
Enter your age:
45
Enter position number:
4
After adding a person, the list is:
Gayathri;USA;22
Stephanie;USA;27
Priya;India;34
Ahmed;Nigeria;52
Arely;Mexico;45
Thank you for using my Citizen Database!!

More Related Content

Similar to PLEASE HELP IN C++For this test, you will need to create the follo.pdf

TOPIC-2-Expression Variable Assignment Statement.pdf
TOPIC-2-Expression Variable Assignment Statement.pdfTOPIC-2-Expression Variable Assignment Statement.pdf
TOPIC-2-Expression Variable Assignment Statement.pdfEjazAlam23
 
3. Section 3 � Complete functionality on listing screen (1.5 marks.pdf
3. Section 3 � Complete functionality on listing screen (1.5 marks.pdf3. Section 3 � Complete functionality on listing screen (1.5 marks.pdf
3. Section 3 � Complete functionality on listing screen (1.5 marks.pdfalliedscorporation
 
Create a menu-driven program that will accept a collection of non-ne.pdf
Create a menu-driven program that will accept a collection of non-ne.pdfCreate a menu-driven program that will accept a collection of non-ne.pdf
Create a menu-driven program that will accept a collection of non-ne.pdfrajeshjangid1865
 
Should be in JavaInterface Worker should extend Serializable from .pdf
Should be in JavaInterface Worker should extend Serializable from .pdfShould be in JavaInterface Worker should extend Serializable from .pdf
Should be in JavaInterface Worker should extend Serializable from .pdffashionscollect
 
Write codeforhumans
Write codeforhumansWrite codeforhumans
Write codeforhumansNarendran R
 
Python Programming by Dr. C. Sreedhar.pdf
Python Programming by Dr. C. Sreedhar.pdfPython Programming by Dr. C. Sreedhar.pdf
Python Programming by Dr. C. Sreedhar.pdfSreedhar Chowdam
 
L11a Create the Student class derived from the Person class- A student.docx
L11a Create the Student class derived from the Person class- A student.docxL11a Create the Student class derived from the Person class- A student.docx
L11a Create the Student class derived from the Person class- A student.docxJacob6ALMcDonaldu
 
Chapter2pp
Chapter2ppChapter2pp
Chapter2ppJ. C.
 
Linq And Its Impact On The.Net Framework
Linq And Its Impact On The.Net FrameworkLinq And Its Impact On The.Net Framework
Linq And Its Impact On The.Net Frameworkrushputin
 
Антон Молдован "Type driven development with f#"
Антон Молдован "Type driven development with f#"Антон Молдован "Type driven development with f#"
Антон Молдован "Type driven development with f#"Fwdays
 
Implementation Your program shall contain at least the follo.pdf
Implementation Your program shall contain at least the follo.pdfImplementation Your program shall contain at least the follo.pdf
Implementation Your program shall contain at least the follo.pdfADITIEYEWEAR
 
All you need to know about JavaScript Functions
All you need to know about JavaScript FunctionsAll you need to know about JavaScript Functions
All you need to know about JavaScript FunctionsOluwaleke Fakorede
 
String Assignment Java 1115Write a program that plays a word game .pdf
String Assignment Java 1115Write a program that plays a word game .pdfString Assignment Java 1115Write a program that plays a word game .pdf
String Assignment Java 1115Write a program that plays a word game .pdfayubkota
 
Preexisting code, please useMain.javapublic class Main { p.pdf
Preexisting code, please useMain.javapublic class Main {    p.pdfPreexisting code, please useMain.javapublic class Main {    p.pdf
Preexisting code, please useMain.javapublic class Main { p.pdfrd1742
 

Similar to PLEASE HELP IN C++For this test, you will need to create the follo.pdf (20)

TOPIC-2-Expression Variable Assignment Statement.pdf
TOPIC-2-Expression Variable Assignment Statement.pdfTOPIC-2-Expression Variable Assignment Statement.pdf
TOPIC-2-Expression Variable Assignment Statement.pdf
 
3. Section 3 � Complete functionality on listing screen (1.5 marks.pdf
3. Section 3 � Complete functionality on listing screen (1.5 marks.pdf3. Section 3 � Complete functionality on listing screen (1.5 marks.pdf
3. Section 3 � Complete functionality on listing screen (1.5 marks.pdf
 
Create a menu-driven program that will accept a collection of non-ne.pdf
Create a menu-driven program that will accept a collection of non-ne.pdfCreate a menu-driven program that will accept a collection of non-ne.pdf
Create a menu-driven program that will accept a collection of non-ne.pdf
 
Should be in JavaInterface Worker should extend Serializable from .pdf
Should be in JavaInterface Worker should extend Serializable from .pdfShould be in JavaInterface Worker should extend Serializable from .pdf
Should be in JavaInterface Worker should extend Serializable from .pdf
 
Write codeforhumans
Write codeforhumansWrite codeforhumans
Write codeforhumans
 
Python Programming by Dr. C. Sreedhar.pdf
Python Programming by Dr. C. Sreedhar.pdfPython Programming by Dr. C. Sreedhar.pdf
Python Programming by Dr. C. Sreedhar.pdf
 
L11a Create the Student class derived from the Person class- A student.docx
L11a Create the Student class derived from the Person class- A student.docxL11a Create the Student class derived from the Person class- A student.docx
L11a Create the Student class derived from the Person class- A student.docx
 
Python Part 1
Python Part 1Python Part 1
Python Part 1
 
Chapter2pp
Chapter2ppChapter2pp
Chapter2pp
 
Java 8 revealed
Java 8 revealedJava 8 revealed
Java 8 revealed
 
Linq And Its Impact On The.Net Framework
Linq And Its Impact On The.Net FrameworkLinq And Its Impact On The.Net Framework
Linq And Its Impact On The.Net Framework
 
OpenAI API crash course
OpenAI API crash courseOpenAI API crash course
OpenAI API crash course
 
Антон Молдован "Type driven development with f#"
Антон Молдован "Type driven development with f#"Антон Молдован "Type driven development with f#"
Антон Молдован "Type driven development with f#"
 
Python Programming
Python ProgrammingPython Programming
Python Programming
 
Implementation Your program shall contain at least the follo.pdf
Implementation Your program shall contain at least the follo.pdfImplementation Your program shall contain at least the follo.pdf
Implementation Your program shall contain at least the follo.pdf
 
All you need to know about JavaScript Functions
All you need to know about JavaScript FunctionsAll you need to know about JavaScript Functions
All you need to know about JavaScript Functions
 
String Assignment Java 1115Write a program that plays a word game .pdf
String Assignment Java 1115Write a program that plays a word game .pdfString Assignment Java 1115Write a program that plays a word game .pdf
String Assignment Java 1115Write a program that plays a word game .pdf
 
PostThis
PostThisPostThis
PostThis
 
Preexisting code, please useMain.javapublic class Main { p.pdf
Preexisting code, please useMain.javapublic class Main {    p.pdfPreexisting code, please useMain.javapublic class Main {    p.pdf
Preexisting code, please useMain.javapublic class Main { p.pdf
 
Linq
LinqLinq
Linq
 

More from aioils

Please help solve! Suppose that X is an exponential random variable .pdf
Please help solve! Suppose that X is an exponential random variable .pdfPlease help solve! Suppose that X is an exponential random variable .pdf
Please help solve! Suppose that X is an exponential random variable .pdfaioils
 
Please help me with a UML class diagram for the following code im.pdf
Please help me with a UML class diagram for the following code im.pdfPlease help me with a UML class diagram for the following code im.pdf
Please help me with a UML class diagram for the following code im.pdfaioils
 
Please help me i will give good rating a) A wheel has 37 numbers 0.pdf
Please help me i will give good rating  a) A wheel has 37 numbers 0.pdfPlease help me i will give good rating  a) A wheel has 37 numbers 0.pdf
Please help me i will give good rating a) A wheel has 37 numbers 0.pdfaioils
 
Please help me answer this question.Explain how oxygen content acc.pdf
Please help me answer this question.Explain how oxygen content acc.pdfPlease help me answer this question.Explain how oxygen content acc.pdf
Please help me answer this question.Explain how oxygen content acc.pdfaioils
 
please help and thank you ! Experiments by Murphy et al. (2014) on t.pdf
please help and thank you ! Experiments by Murphy et al. (2014) on t.pdfplease help and thank you ! Experiments by Murphy et al. (2014) on t.pdf
please help and thank you ! Experiments by Murphy et al. (2014) on t.pdfaioils
 
PLEASE HELP (also please dont answer with path because there is no .pdf
PLEASE HELP (also please dont answer with path because there is no .pdfPLEASE HELP (also please dont answer with path because there is no .pdf
PLEASE HELP (also please dont answer with path because there is no .pdfaioils
 
please explain these topics if possible How companies account for.pdf
please explain these topics if possible  How companies account for.pdfplease explain these topics if possible  How companies account for.pdf
please explain these topics if possible How companies account for.pdfaioils
 
Pls introduced to various themes and theoretical issues pertaining t.pdf
Pls introduced to various themes and theoretical issues pertaining t.pdfPls introduced to various themes and theoretical issues pertaining t.pdf
Pls introduced to various themes and theoretical issues pertaining t.pdfaioils
 
please! 1. Match and pair the following basic genetic conce.pdf
please!  1. Match and pair the following basic genetic conce.pdfplease!  1. Match and pair the following basic genetic conce.pdf
please! 1. Match and pair the following basic genetic conce.pdfaioils
 
Please write out steps )You have genotyped an entire population o.pdf
Please write out steps )You have genotyped an entire population o.pdfPlease write out steps )You have genotyped an entire population o.pdf
Please write out steps )You have genotyped an entire population o.pdfaioils
 
Please write out the steps )_You have genotyped an entire populat.pdf
Please write out the steps )_You have genotyped an entire populat.pdfPlease write out the steps )_You have genotyped an entire populat.pdf
Please write out the steps )_You have genotyped an entire populat.pdfaioils
 
Please Use The Code Provided below. Thanks Study the Python code .pdf
Please Use The Code Provided below. Thanks  Study the Python code .pdfPlease Use The Code Provided below. Thanks  Study the Python code .pdf
Please Use The Code Provided below. Thanks Study the Python code .pdfaioils
 
Please Use the Code Provided below. Thanks Visit LL Queue ; add.pdf
Please Use the Code Provided below. Thanks  Visit LL Queue ; add.pdfPlease Use the Code Provided below. Thanks  Visit LL Queue ; add.pdf
Please Use the Code Provided below. Thanks Visit LL Queue ; add.pdfaioils
 
Please this is very important Im on a deadline The joint probabilit.pdf
Please this is very important Im on a deadline The joint probabilit.pdfPlease this is very important Im on a deadline The joint probabilit.pdf
Please this is very important Im on a deadline The joint probabilit.pdfaioils
 
Please solve. In the Assembly Department of Martinez Company, budget.pdf
Please solve. In the Assembly Department of Martinez Company, budget.pdfPlease solve. In the Assembly Department of Martinez Company, budget.pdf
Please solve. In the Assembly Department of Martinez Company, budget.pdfaioils
 
Please do parts labeled TODO LinkedList.java Replace.pdf
Please do parts labeled TODO LinkedList.java Replace.pdfPlease do parts labeled TODO LinkedList.java Replace.pdf
Please do parts labeled TODO LinkedList.java Replace.pdfaioils
 
Please do Part A, Ill be really gratefulThe main.c is the skeleto.pdf
Please do Part A, Ill be really gratefulThe main.c is the skeleto.pdfPlease do Part A, Ill be really gratefulThe main.c is the skeleto.pdf
Please do Part A, Ill be really gratefulThe main.c is the skeleto.pdfaioils
 
Please do number 1 as its my choice for this project but, if there.pdf
Please do number 1 as its my choice for this project but, if there.pdfPlease do number 1 as its my choice for this project but, if there.pdf
Please do number 1 as its my choice for this project but, if there.pdfaioils
 
Please show workstepsYou have genotyped an entire population of l.pdf
Please show workstepsYou have genotyped an entire population of l.pdfPlease show workstepsYou have genotyped an entire population of l.pdf
Please show workstepsYou have genotyped an entire population of l.pdfaioils
 
Please show all steps of algebra. I have the answer shown below but .pdf
Please show all steps of algebra. I have the answer shown below but .pdfPlease show all steps of algebra. I have the answer shown below but .pdf
Please show all steps of algebra. I have the answer shown below but .pdfaioils
 

More from aioils (20)

Please help solve! Suppose that X is an exponential random variable .pdf
Please help solve! Suppose that X is an exponential random variable .pdfPlease help solve! Suppose that X is an exponential random variable .pdf
Please help solve! Suppose that X is an exponential random variable .pdf
 
Please help me with a UML class diagram for the following code im.pdf
Please help me with a UML class diagram for the following code im.pdfPlease help me with a UML class diagram for the following code im.pdf
Please help me with a UML class diagram for the following code im.pdf
 
Please help me i will give good rating a) A wheel has 37 numbers 0.pdf
Please help me i will give good rating  a) A wheel has 37 numbers 0.pdfPlease help me i will give good rating  a) A wheel has 37 numbers 0.pdf
Please help me i will give good rating a) A wheel has 37 numbers 0.pdf
 
Please help me answer this question.Explain how oxygen content acc.pdf
Please help me answer this question.Explain how oxygen content acc.pdfPlease help me answer this question.Explain how oxygen content acc.pdf
Please help me answer this question.Explain how oxygen content acc.pdf
 
please help and thank you ! Experiments by Murphy et al. (2014) on t.pdf
please help and thank you ! Experiments by Murphy et al. (2014) on t.pdfplease help and thank you ! Experiments by Murphy et al. (2014) on t.pdf
please help and thank you ! Experiments by Murphy et al. (2014) on t.pdf
 
PLEASE HELP (also please dont answer with path because there is no .pdf
PLEASE HELP (also please dont answer with path because there is no .pdfPLEASE HELP (also please dont answer with path because there is no .pdf
PLEASE HELP (also please dont answer with path because there is no .pdf
 
please explain these topics if possible How companies account for.pdf
please explain these topics if possible  How companies account for.pdfplease explain these topics if possible  How companies account for.pdf
please explain these topics if possible How companies account for.pdf
 
Pls introduced to various themes and theoretical issues pertaining t.pdf
Pls introduced to various themes and theoretical issues pertaining t.pdfPls introduced to various themes and theoretical issues pertaining t.pdf
Pls introduced to various themes and theoretical issues pertaining t.pdf
 
please! 1. Match and pair the following basic genetic conce.pdf
please!  1. Match and pair the following basic genetic conce.pdfplease!  1. Match and pair the following basic genetic conce.pdf
please! 1. Match and pair the following basic genetic conce.pdf
 
Please write out steps )You have genotyped an entire population o.pdf
Please write out steps )You have genotyped an entire population o.pdfPlease write out steps )You have genotyped an entire population o.pdf
Please write out steps )You have genotyped an entire population o.pdf
 
Please write out the steps )_You have genotyped an entire populat.pdf
Please write out the steps )_You have genotyped an entire populat.pdfPlease write out the steps )_You have genotyped an entire populat.pdf
Please write out the steps )_You have genotyped an entire populat.pdf
 
Please Use The Code Provided below. Thanks Study the Python code .pdf
Please Use The Code Provided below. Thanks  Study the Python code .pdfPlease Use The Code Provided below. Thanks  Study the Python code .pdf
Please Use The Code Provided below. Thanks Study the Python code .pdf
 
Please Use the Code Provided below. Thanks Visit LL Queue ; add.pdf
Please Use the Code Provided below. Thanks  Visit LL Queue ; add.pdfPlease Use the Code Provided below. Thanks  Visit LL Queue ; add.pdf
Please Use the Code Provided below. Thanks Visit LL Queue ; add.pdf
 
Please this is very important Im on a deadline The joint probabilit.pdf
Please this is very important Im on a deadline The joint probabilit.pdfPlease this is very important Im on a deadline The joint probabilit.pdf
Please this is very important Im on a deadline The joint probabilit.pdf
 
Please solve. In the Assembly Department of Martinez Company, budget.pdf
Please solve. In the Assembly Department of Martinez Company, budget.pdfPlease solve. In the Assembly Department of Martinez Company, budget.pdf
Please solve. In the Assembly Department of Martinez Company, budget.pdf
 
Please do parts labeled TODO LinkedList.java Replace.pdf
Please do parts labeled TODO LinkedList.java Replace.pdfPlease do parts labeled TODO LinkedList.java Replace.pdf
Please do parts labeled TODO LinkedList.java Replace.pdf
 
Please do Part A, Ill be really gratefulThe main.c is the skeleto.pdf
Please do Part A, Ill be really gratefulThe main.c is the skeleto.pdfPlease do Part A, Ill be really gratefulThe main.c is the skeleto.pdf
Please do Part A, Ill be really gratefulThe main.c is the skeleto.pdf
 
Please do number 1 as its my choice for this project but, if there.pdf
Please do number 1 as its my choice for this project but, if there.pdfPlease do number 1 as its my choice for this project but, if there.pdf
Please do number 1 as its my choice for this project but, if there.pdf
 
Please show workstepsYou have genotyped an entire population of l.pdf
Please show workstepsYou have genotyped an entire population of l.pdfPlease show workstepsYou have genotyped an entire population of l.pdf
Please show workstepsYou have genotyped an entire population of l.pdf
 
Please show all steps of algebra. I have the answer shown below but .pdf
Please show all steps of algebra. I have the answer shown below but .pdfPlease show all steps of algebra. I have the answer shown below but .pdf
Please show all steps of algebra. I have the answer shown below but .pdf
 

Recently uploaded

Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdfTechSoup
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxJheel Barad
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfjoachimlavalley1
 
678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdfCarlosHernanMontoyab2
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxJisc
 
The Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve ThomasonThe Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve ThomasonSteve Thomason
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasGeoBlogs
 
How to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS ModuleHow to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS ModuleCeline George
 
How to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPHow to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPCeline George
 
Basic Civil Engineering Notes of Chapter-6, Topic- Ecosystem, Biodiversity G...
Basic Civil Engineering Notes of Chapter-6,  Topic- Ecosystem, Biodiversity G...Basic Civil Engineering Notes of Chapter-6,  Topic- Ecosystem, Biodiversity G...
Basic Civil Engineering Notes of Chapter-6, Topic- Ecosystem, Biodiversity G...Denish Jangid
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXMIRIAMSALINAS13
 
Matatag-Curriculum and the 21st Century Skills Presentation.pptx
Matatag-Curriculum and the 21st Century Skills Presentation.pptxMatatag-Curriculum and the 21st Century Skills Presentation.pptx
Matatag-Curriculum and the 21st Century Skills Presentation.pptxJenilouCasareno
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationDelapenabediema
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaasiemaillard
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxRaedMohamed3
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfkaushalkr1407
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismDeeptiGupta154
 
UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...
UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...
UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...Sayali Powar
 

Recently uploaded (20)

Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
 
678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 
The Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve ThomasonThe Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve Thomason
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
 
How to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS ModuleHow to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS Module
 
How to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPHow to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERP
 
Basic Civil Engineering Notes of Chapter-6, Topic- Ecosystem, Biodiversity G...
Basic Civil Engineering Notes of Chapter-6,  Topic- Ecosystem, Biodiversity G...Basic Civil Engineering Notes of Chapter-6,  Topic- Ecosystem, Biodiversity G...
Basic Civil Engineering Notes of Chapter-6, Topic- Ecosystem, Biodiversity G...
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
 
Matatag-Curriculum and the 21st Century Skills Presentation.pptx
Matatag-Curriculum and the 21st Century Skills Presentation.pptxMatatag-Curriculum and the 21st Century Skills Presentation.pptx
Matatag-Curriculum and the 21st Century Skills Presentation.pptx
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
B.ed spl. HI pdusu exam paper-2023-24.pdf
B.ed spl. HI pdusu exam paper-2023-24.pdfB.ed spl. HI pdusu exam paper-2023-24.pdf
B.ed spl. HI pdusu exam paper-2023-24.pdf
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
 
UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...
UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...
UNIT – IV_PCI Complaints: Complaints and evaluation of complaints, Handling o...
 

PLEASE HELP IN C++For this test, you will need to create the follo.pdf

  • 1. PLEASE HELP IN C++ For this test, you will need to create the following function. First add the function prototype to person.h, then put the function implementation in person.cpp and finally invoke/test the function in main.cpp. Please label your output clearly. E.g. After adding a person, the list is: Create a function to read a persons information and insert into the list at a given position. The function returns true if the insertion is successful and it returns false if the array is out of capacity. bool addPerson(PersonType list[], int &count); Sample code in person.cpp PersonType aPerson; //read in person name, person citizenship, and age and populate aPerson //e.g strcpy(aPerson.name, tempName) //read position to insert inside the function - see sample //run //position could be read from the user or you could set a //number that is not more than count. If you read from the //user, check to make sure position is not > than count. //shift and insert aPerson in the right position Sample test code in main.cpp if(addPerson(list, count) == true) {output list} You must be able to read cstrings with spaces. You must not replace any existing values in the list. You must shift and insert in the right position. See zybooks Lab 11.9 for reference. You must be able to add at the beginning of the list and at the end - if your list has 4 elements, users must be able to insert at position 0 through 4. See Sample Runs below and test your code multiple times adding users at the beginning and at the end. You must make sure the position is within count. You must check for unreasonable age (for example: age < 1 and age > 100 can be unreasonable). Include a welcome and goodbye message. (See sample run below). Must use all the given function prototypes under Task exactly as is. Function Prototypes and implementations must be written in the appropriate files. Do not add header comments for this exam, but you must have function comments for the function you are writing. Do not use containers of any sort or any vectors for this program. Use only the concepts we have
  • 2. learned so far. Criteria for Success Test your program using the following sample runs, making sure you get the same output when using the given inputs (in blue): Welcome to my Citizens Database. Here is your list so far: Gayathri;USA;22 Stephanie;USA;27 Priya;India;34 Ahmed;Nigeria;52 Enter your name: Navid Enter your citizenship: Ecuador Enter your age: 34 Enter position number: 2 After adding a person, the list is: Gayathri;USA;22 Stephanie;USA;27 Navid;Ecuador;34 Priya;India;34 Ahmed;Nigeria;52 Thank you for using my Citizen Database!! Welcome to my Citizens Database. Here is your list so far: Gayathri;USA;22 Stephanie;USA;27 Priya;India;34 Ahmed;Nigeria;52 Enter your name: Navid Enter your citizenship: Ecuador Enter your age:
  • 3. 34 Enter position number: 9 Error! Invalid position. Thank you for using my Citizen Database!! Welcome to my Citizens Database. Here is your list so far: Gayathri;USA;22 Stephanie;USA;27 Priya;India;34 Ahmed;Nigeria;52 Enter your name: Lucy Enter your citizenship: Ecuador Enter your age: 34 Enter position number: 0 After adding a person, the list is: Lucy;Ecuador;34 Gayathri;USA;22 Stephanie;USA;27 Priya;India;34 Ahmed;Nigeria;52 Thank you for using my Citizen Database!! Welcome to my Citizens Database. Here is your list so far: Gayathri;USA;22 Stephanie;USA;27 Priya;India;34 Ahmed;Nigeria;52 Enter your name: Arely Enter your citizenship: Mexico
  • 4. Enter your age: 45 Enter position number: 4 After adding a person, the list is: Gayathri;USA;22 Stephanie;USA;27 Priya;India;34 Ahmed;Nigeria;52 Arely;Mexico;45 Thank you for using my Citizen Database!! You must be able to read cstrings with spaces. You must not replace any existing values in the list. You must shift and insert in the right position. See zybooks Lab 11.9 for reference. You must be able to add at the beginning of the list and at the end - if your list has 4 elements, users must be able to insert at position 0 through 4. See Sample Runs below and test your code multiple times adding users at the beginning and at the end. You must make sure the position is within count. You must check for unreasonable age (for example: age < 1 and age > 100 can be unreasonable). Include a welcome and goodbye message. (See sample run). Must use all the given function prototypes under Task exactly as is. Function Prototypes and implementations must be written in the appropriate files. Do not add header comments for this exam, but you must have function comments for the function you are writing. Do not use containers of any sort or any vectors for this program. Use only the concepts we have learned so far. THIS IS THE CODE PROVIDED MAIN.CPP //main driver file //add header comments here. #include "person.h" const int CAPACITY = 20; //function protoypes
  • 5. //main and then functions. int main() { PersonType list[CAPACITY]; int count = 0; char fileName[] = "persons.txt"; populatePersons(list, count, fileName); printPersons(list, count); //call your functions here to do what is required. return 0; } PERSON.CPP //function to print list void printPersons(const PersonType list[], int count) { cout << "List of citizen database!" << endl; for(int index = 0; index < count; index++) { cout << list[index].name << ";" << list[index].citizenship; cout << ";" << list[index].age << endl; } } //add your function here for removePersons.....) void setName(string name_input); void setGpa(float gpa_input); void setEnrollYear(int enrollYear_input); void setRollNumber(int rollNumber_input); void displayStudent(); string getName(); float getGpa(); int getEnrollYear(); int getRollNumber(); }; PERSON.H //struct for PersonType
  • 6. #pragma once #include #include #include using namespace std; const int MAX_CHAR = 101; struct PersonType { char name[MAX_CHAR]; char citizenship[MAX_CHAR]; int age; }; //function prototypes void populatePersons(PersonType list[], int& count, const char fileName[]); void printPersons(const PersonType list[], int count); //add your function prototype here. PERSON.TXT Gayathri USA 22 Stephanie USA 27 Priya India 34 Ahmed Nigeria 52 Welcome to my Citizens Database. Here is your list so far: Gayathri;USA;22 Stephanie;USA;27 Priya;India;34 Ahmed;Nigeria;52 Enter your name: Navid Enter your citizenship: Ecuador Enter your age: 34 Enter position number:
  • 7. 2 After adding a person, the list is: Gayathri;USA;22 Stephanie;USA;27 Navid;Ecuador;34 Priya;India;34 Ahmed;Nigeria;52 Thank you for using my Citizen Database!! Welcome to my Citizens Database. Here is your list so far: Gayathri;USA;22 Stephanie;USA;27 Priya;India;34 Ahmed;Nigeria;52 Enter your name: Navid Enter your citizenship: Ecuador Enter your age: 34 Enter position number: 9 Error! Invalid position. Thank you for using my Citizen Database!! Welcome to my Citizens Database. Here is your list so far: Gayathri;USA;22 Stephanie;USA;27 Priya;India;34 Ahmed;Nigeria;52 Enter your name: Lucy Enter your citizenship: Ecuador Enter your age: 34
  • 8. Enter position number: 0 After adding a person, the list is: Lucy;Ecuador;34 Gayathri;USA;22 Stephanie;USA;27 Priya;India;34 Ahmed;Nigeria;52 Thank you for using my Citizen Database!! Welcome to my Citizens Database. Here is your list so far: Gayathri;USA;22 Stephanie;USA;27 Priya;India;34 Ahmed;Nigeria;52 Enter your name: Arely Enter your citizenship: Mexico Enter your age: 45 Enter position number: 4 After adding a person, the list is: Gayathri;USA;22 Stephanie;USA;27 Priya;India;34 Ahmed;Nigeria;52 Arely;Mexico;45 Thank you for using my Citizen Database!!