Menu

[solved]-Need Help Arrays One Holds Name Divisions North East West Central One Holds Values Please Q39022357

Need help doing this with arrays: one that holds the name of thedivisions (North, East, west, central) and one that holds thevalues of both, please dont use dinamic arrays;(is a 3 fileclass)

#ifndef accidente_hpp

#define accidente_hpp

#include<iomanip>

#include<iostream>

class Accidente

{

private:

double north;

double south;

double east;

double west;

double center;

public:

Accidente();

Accidente(double, double,double,double,double);

void setNorth(double);

void setSouth(double);

void setEast(double);

void setWest(double);

void setCentral(double);

double getRegionN()const;

double getRegionS()const;

double getRegionE()const;

double getRegionW()const;

double getRegionC()const;

//intfindLowest(double,double,double,double,double);

};

#endif /* accidente_h */
************************************************************​​​​​​​********************​​​​​​​********************​​​​​​​********************

#include “accidente.hpp”

#include <iostream>

#include <iomanip>

#include <cmath>

using namespace std;

Accidente::Accidente()

{

north=0;

south=0;

east=0;

west=0;

center=0;

}

Accidente::Accidente(doublen,double s, double e,double w,double c)

{

north=n;

south=s;

east=e;

west=w;

center=c;

  

}

voidAccidente::setNorth(double n)

{

if(n>=0)

north=n;

else

{

cout<<“Invalid inputn”;

exit(EXIT_FAILURE);

}

}

voidAccidente::setSouth(double s)

{

if(s>=0)

south=s;

else

{

cout<<“Invalid inputn”;

exit(EXIT_FAILURE);

}

}

void Accidente::setEast(doublee)

{

if(e>=0)

east=e;

else

{

cout<<“Invalid inputn”;

exit(EXIT_FAILURE);

}

}

void Accidente::setWest(doublew)

{

if(w>=0)

west=w;

else

{

cout<<“Invalid inputn”;

exit(EXIT_FAILURE);

}

}

voidAccidente::setCentral(double c)

{

if(c>=0)

center=c;

else

{

cout<<“Invalid inputn”;

exit(EXIT_FAILURE);

}

}

doubleAccidente::getRegionN()const

{

return north;

}

doubleAccidente::getRegionS()const

{

return south;

}

doubleAccidente::getRegionE()const

{

return east;

}

doubleAccidente::getRegionW()const

{

return west;

}

doubleAccidente::getRegionC()const

{

return center;

}

*********************************************************************************************************************

this is main

#include “accidente.hpp”

#include <iostream>

#include <iomanip>

#include <cmath>

using namespace std;

int main()

{

Accidente crash;

doubleRN,RS,RE,RW,RC;//Region(N)orte

  

cout<<“How many accidents happen in region North:”<<“0 is not accepted”<<endl;

cin>>RN;

cout<<“How many accidents happen in region South:”<<“0 is not accepted”<<endl;

cin>>RS;

cout<<“How many accidents happen in region East:”<<“0 is not accepted”<<endl;

cin>>RE;

cout<<“How many accidents happen in region West:”<<“0 is not accepted”<<endl;

cin>>RW;

cout<<“How many accidents happen in region Central:”<<“0 is not accepted”<<endl;

cin>>RC;

crash.setNorth(RN);

crash.setSouth(RS);

crash.setEast(RE);

crash.setWest(RW);

crash.setCentral(RC);

//crash.findLowest(RN,RS,RE,RW,RC);

   voidfindLowest(double RN,double RS,double RE, doubleRW,double RC);

{

if(RN<=RS && RN<=RW&&RN<=RE && RN<=RC)//north

{

cout<<“The lowest report region is north with:”<<RN;

cout<<endl;

}

if( RS<=RN && RS<=RE&&RS<=RW&& RS<=RC)//sur

{

cout<<“The lowest report region is South with:”<<RS;

cout<<endl;

}

if(RE<=RN && RE<=RW &&RE<=RS && RE<=RC)//este

{

cout<<“the lowest report region is East with:”<<RE;

cout<<endl;

}

if(RW<=RN && RW<=RS &&RW<=RE && RW<=RC)//oeste

{

cout<<“The lowest report region is West with: “<<RW;

cout<<endl;

}

if(RC<=RN && RC<=RE &&RC<=RW && RC<=RS)//oeste

{

cout<<“The lowest report region is Central with :”<<RC;

cout<<endl;

}

  

}

cout<<“The accidents reported in Region North are:”<<crash.getRegionN()<<endl;

cout<<“The accidents reported in Region South are:”<<crash.getRegionS()<<endl;

cout<<“The accidents reported in Region East are:”<<crash.getRegionE()<<endl;

cout<<“The accidents reported in Region West are:”<<crash.getRegionW()<<endl;

cout<<“The accidents reported in Region Central are:”<<crash.getRegionC()<<endl;

//crash.findLowest(RN,RS,RE,RW,RC);

  

  

}

Expert Answer


Answer to Need help doing this with arrays: one that holds the name of the divisions (North, East, west, central) and one that hol… . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *