i've started doing structure today so i'm still not perfect to them.my lecturer has asked me to this program so i really need ur suggestions about it.
The following information is available of each of 6 pets.
Kind of pet ( for example Marmoset monkey)
Name of pet (e.g Penta)
Age of pet (e.g 10 yrs)
Gender of pet (M if male, F if female)
Only pet of family (true or false)
Value of pet (e.g. R120.00)
Task 1
Write down the declaration for a struct containing the information of a single pet
Task 2
Write down the declaration of an array of 6 structs that will contain the information of 6 pets
Task 3
Write a function getInput which will input the information for 6 pets
Task 4
Write a function displayKindAndN ame which will display the kind and name of every pet of age 5 or above
Task 5
Write a main function to call the other two functions. Use the test data given below to run your program and submit printouts of the program and output.
so i've done the first function and it is giving me an error that i can't figure out the problem about it.this is my code.
[code=c++]
include<iostrea m>
using namespace std;
#include<string >
struct Pet{
string kind;
char name;
int age;
char gender;
char family;
double value;
};
void GetInput(char&, char&,int&,char &,char&,double& );
void DisplayKindAndN ame(string[],int[]);
int main()
{
Pet information[6];
Pet Results;
Pet kind;
Pet name;
Pet age;
Pet gender;
Pet family;
Pet value;
GetInput(kind,n ame,age,gender, family,value);
return 0;
}
void GetInput(char&k ind,char&Name,i nt&Age,char&Gen der,char&Family ,double&Value)
{
cout<<"please enter the kind of the pet(e.g.Marmose t monkey) \n";
cin>>kind;
cout<<"please enter the name of the pet(e.g.Penta)\ n";
cin>>Name;
cout<<"Please enter the age of ther pet(e.g. 10 yrs)\n";
cin>>Age;
cout<<"Please may you enter the gender of the pet(M if male, F if female) \n";
cin>>Gender;
cout<<"Is that the Only pet of family (true or false) \n";
cin>>Family;
cout<<"What is the value of the pet?(e.g. R120.00)\n";
cin>>Value;
}
The following information is available of each of 6 pets.
Kind of pet ( for example Marmoset monkey)
Name of pet (e.g Penta)
Age of pet (e.g 10 yrs)
Gender of pet (M if male, F if female)
Only pet of family (true or false)
Value of pet (e.g. R120.00)
Task 1
Write down the declaration for a struct containing the information of a single pet
Task 2
Write down the declaration of an array of 6 structs that will contain the information of 6 pets
Task 3
Write a function getInput which will input the information for 6 pets
Task 4
Write a function displayKindAndN ame which will display the kind and name of every pet of age 5 or above
Task 5
Write a main function to call the other two functions. Use the test data given below to run your program and submit printouts of the program and output.
so i've done the first function and it is giving me an error that i can't figure out the problem about it.this is my code.
[code=c++]
include<iostrea m>
using namespace std;
#include<string >
struct Pet{
string kind;
char name;
int age;
char gender;
char family;
double value;
};
void GetInput(char&, char&,int&,char &,char&,double& );
void DisplayKindAndN ame(string[],int[]);
int main()
{
Pet information[6];
Pet Results;
Pet kind;
Pet name;
Pet age;
Pet gender;
Pet family;
Pet value;
GetInput(kind,n ame,age,gender, family,value);
return 0;
}
void GetInput(char&k ind,char&Name,i nt&Age,char&Gen der,char&Family ,double&Value)
{
cout<<"please enter the kind of the pet(e.g.Marmose t monkey) \n";
cin>>kind;
cout<<"please enter the name of the pet(e.g.Penta)\ n";
cin>>Name;
cout<<"Please enter the age of ther pet(e.g. 10 yrs)\n";
cin>>Age;
cout<<"Please may you enter the gender of the pet(M if male, F if female) \n";
cin>>Gender;
cout<<"Is that the Only pet of family (true or false) \n";
cin>>Family;
cout<<"What is the value of the pet?(e.g. R120.00)\n";
cin>>Value;
}
Comment