Write a C++ program which will accept miss Dodoma contestant. The contestant is described through: contestant surname, contestant identification number, gender, age, weight, height,
registrationstatus. The registration status is valued as either true or false. Your program should:
- Accept the values via assignment operator.
- Display the accepted values on the screen
- Overwrite the previously values by the values accepted from user.
-Display the current values on the screen.
#include <iostream>
using namespace std;
struct Miss
{
string surname;
long long int id;
string gender;
unsigned int age;
double weight;
double height;
bool reg_status;
};
Miss * accept()
{
Miss *Dodoma = new Miss();
cout << "surname=";
cin >> Dodoma->surname;
cout << "id=";
cin >> Dodoma->id;
cout << "gender=";
cin >> Dodoma->gender;
cout << "age=";
cin >> Dodoma->age;
cout << "weight=";
cin >> Dodoma->weight;
cout << "height=";
cin >> Dodoma->height;
cout << "register_status=";
cin >> Dodoma->reg_status;
return Dodoma;
}
void display(Miss *Dodoma)
{
cout << "surname=" << Dodoma->surname << "\n";
cout << "id=" << Dodoma->id << "\n";
cout << "gender=" << Dodoma->gender << "\n";
cout << "age=" << Dodoma->age << "\n";
cout << "weight=" << Dodoma->weight << "\n";
cout << "height=" << Dodoma->height << "\n";
cout << "register_status=" << (Dodoma->reg_status ? "true" : "false") << "\n";
}
int main()
{
Miss *Dodoma;
cout << "<<<accept data>>>\n";
Dodoma = accept();
cout << "<<<display>>>\n";
display(Dodoma);
cout << "<<<edit data>>>\n";
Dodoma = accept();
cout << "<<<display>>>\n";
display(Dodoma);
delete Dodoma;
return 0;
}
Comments
Leave a comment