What's new

****

Status
Not open for further replies.

Xyrrk

Eternal Poster
Established
Joined
Oct 8, 2017
Posts
671
Solutions
2
Reaction
212
Points
400
Screenshot_2022-02-23-08-55-41-44_e2d5b3f32b79de1d45acd1fad96fbb0f.jpg

Pa help naman need ko idea
 

Attachments

Help sana kita pero java code ang mapoprovide ko 😂

Una hingiin mo yung user input para sa estimated number of residents.
Then gawa ka ng array and iset mo ng size is yung input kanina na estimated number of residents.
Pwede kang gumawa ng class for resident then for every input ng resident, gawa ka lang new resident object. Then for every resident object na yun ipasok mo lang sa array na ginawa mo kanina.
 
Last edited:
Sa tingin ko kung person's details dapat struct yan at hindi array para mas coherent ang relationship. Tapos yung victims, vector (array) ng person, eg
Code:
struct person {
  std::string fname;
  std::string lname;
 int age;
  char status;                                                                                                                                                                                            
};
 
nasagot na ba to lods? pwede mo to itry kung hindi pa.

sa model mo

Resident.h

C++:
#include <sstream>

using namespace std;

struct Resident {

    string Name;

    int Age;

    char Condition;

};



tapos sa main.cpp mo

whatever_name_ng_program_mo.cpp

C++:
#include <iostream>
#include <sstream>
#include "Resident.h";

using namespace std;

int main()
{
    string barangayName;

    int estimatedNumberOfResidents=0;
    int c = 0;
    int actualEnteredNumber = 0;
    bool isFinished = false;
    char moreEntry;
   
    cout << "Earthquake Incident \n";

    cout << "Name of Barangay: ";
    cin >> barangayName;

    cout << "Estimated number of residents: ";
    cin >> estimatedNumberOfResidents;
    cout << endl << endl;

    Resident * residentList = new Resident[estimatedNumberOfResidents];

    do
    {
       
        Resident* resident = new Resident;
        cout << "Name: ";
        cin >> resident->Name;
        cout << "Age: ";
        cin >> resident->Age;
        cout << "Condition (A,D,I or M): ";
        cin >> resident->Condition;

        residentList[actualEnteredNumber] = *resident;


        cout << "More Entry (Y/N)? ";
        cin >> moreEntry;

        actualEnteredNumber++;
        if(moreEntry == 'N' || actualEnteredNumber >= estimatedNumberOfResidents)
            isFinished = true;

        cout << endl;

    } while (!isFinished);

   
   
    cout << "List of Victims/Casualties" << endl;
    cout << "Name \t" << "Age \t" << "Condition" << endl;
   
    for (c = 0; c < actualEnteredNumber; c++)
    {
        cout << residentList[c].Name <<"\t"<< residentList[c].Age << "\t" << residentList[c].Condition<<endl;
    }

    delete[] residentList;

}
 
Status
Not open for further replies.

Similar threads

Back
Top