****

Status
Not open for further replies.

Elecit23

Eternal Poster
Screenshot_2022-02-23-08-55-41-44_e2d5b3f32b79de1d45acd1fad96fbb0f.webp

Pa help naman need ko idea
 
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.
 
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.

About this Thread

  • 6
    Replies
  • 486
    Views
  • 6
    Participants
Last reply from:
fazz12

Online now

Members online
971
Guests online
1,508
Total visitors
2,479

Forum statistics

Threads
2,276,200
Posts
28,968,256
Members
1,231,160
Latest member
Thanatosbeljke
Back
Top