Answer to Question #195482 in C++ for Alexius

Question #195482

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.


1
Expert's answer
2021-05-19T11:58:36-0400
#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;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog