Question

#include <iostream> #include <string> #include "hashT.h" #include "stateData.h" using namespace std; void stateData::setStateInfo(string sName, string sCapital,...

#include <iostream>

#include <string>

#include "hashT.h"

#include "stateData.h"

using namespace std;

void stateData::setStateInfo(string sName, string sCapital,

   double stArea, int yAdm, int oAdm)

{

  

stateName = sName;

stateCapital = sCapital;

stArea = stateArea;

yAdm = yearOfAdmission;

oAdm = orderOfAdmission;

  

  

}

void stateData::getStateInfo(string& sName, string& sCapital,

   double& stArea, int& yAdm, int& oAdm)

{

  

sName = stateName;

sCapital = stateCapital;

stArea = stateArea;

yAdm = yearOfAdmission;

oAdm = orderOfAdmission;

  

  

}

string stateData::getStateName()

{

return stateName;

}

string stateData::getStateCapitalName()

{

return stateCapital;

}

double stateData::getArea()

{

return stateArea;

}

int stateData::getYearOfAdmission()

{

return yearOfAdmission;

}

int stateData::getOrderOfAdmission()

{

return orderOfAdmission;

}

void stateData::printInfo()

{

cout << "State name: " << stateName << endl;

cout << "Capital name: " << stateCapital << endl;

cout << "Area: " << stateArea << endl;

cout << "Year of admission: " << yearOfAdmission << endl;

cout << "Order of admission: " << orderOfAdmission << endl;

}

bool stateData::operator==(const stateData& right) const

{

return (stateName == right.stateName);

}

bool stateData::operator!=(const stateData& right) const

{

return (stateName != right.stateName);

}

bool stateData::operator> (const stateData& right) const

{

// Fill in this part!

return true;

}

bool stateData::operator< (const stateData& right) const

{

// Fill in this part!

  

return true;

}

ostream& operator<<(ostream& os, const stateData& st)

{

os << "State name: " << st.stateName << endl;

os << "Capital name: " << st.stateCapital << endl;

os << "Area: " << st.stateArea << endl;

os << "Year of admission: " << st.yearOfAdmission << endl;

os << "Order of admission: " << st.orderOfAdmission << endl;

  

return os;

}

istream& operator>>(istream& is, stateData& st)

{

char ch;

getline(is, st.stateName);

getline(is, st.stateCapital);

is >> st.stateArea >> st.yearOfAdmission

>> st.orderOfAdmission;

is.get(ch);

  

return is;

}

Need help with the fill in

C++ Language Please

0 0
Add a comment Improve this question Transcribed image text
Answer #1

In case of any query do comment.

Note: Full Code was not present so I was not able to test it.Below code should give you the expected output.

Code:

First Approach:

bool stateData::operator> (const stateData& right) const

{

// Fill in this part!

return (stateName > right.stateName);

}

bool stateData::operator< (const stateData& right) const

{

return (stateName < right.stateName);

}

Second Approach:

bool stateData::operator> (const stateData& right) const

{

// Fill in this part!

return (stateName.compare(right.stateName) > 0);

}

bool stateData::operator< (const stateData& right) const

{

return (stateName.compare(right.stateName) < 0);

}

Compare method compares the string and return greater than Zero if stateName is greater than right.stateName and return less than Zero if stateName is smaller than right.StateName.

Sample Code output:

main.cpp 1 #include<iostream> 2 using namespace std; 4 int main() string s1 = Testing; string s2 = ABC; if(s1.compare(52)

Add a comment
Know the answer?
Add Answer to:
#include <iostream> #include <string> #include "hashT.h" #include "stateData.h" using namespace std; void stateData::setStateInfo(string sName, string sCapital,...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • #ifndef PROCESSREQUESTRECORD_CLASS #define PROCESSREQUESTRECORD_CLASS #include <iostream> #include <string> using namespace std; class procReqRec { public: //...

    #ifndef PROCESSREQUESTRECORD_CLASS #define PROCESSREQUESTRECORD_CLASS #include <iostream> #include <string> using namespace std; class procReqRec { public: // default constructor procReqRec() {} // constructor procReqRec(const string& nm, int p); // access functions int getPriority(); string getName(); // update functions void setPriority(int p); void setName(const string& nm); // for maintenance of a minimum priority queue friend bool operator< (const procReqRec& left, const procReqRec& right); // output a process request record in the format // name: priority friend ostream& operator<< (ostream& ostr, const procReqRec&...

  • CODES: main.cpp #include <iostream> #include <string> #include "ShoppingCart.h" using namespace std; char PrintMenu() { char answer;...

    CODES: main.cpp #include <iostream> #include <string> #include "ShoppingCart.h" using namespace std; char PrintMenu() { char answer; cout << "MENU" << endl; cout << "a - Add item to cart" << endl; cout << "d - Remove item from cart" << endl; cout << "c - Change item quantity" << endl; cout << "i - Output items' descriptions" << endl; cout << "o - Output shopping cart" << endl; cout << "q - Quit" << endl << endl; while (true) {...

  • lex.h ----------------- #ifndef LEX_H_ #define LEX_H_ #include <string> #include <iostream> using std::string; using std::istream; using std::ostream;...

    lex.h ----------------- #ifndef LEX_H_ #define LEX_H_ #include <string> #include <iostream> using std::string; using std::istream; using std::ostream; enum Token { // keywords PRINT, BEGIN, END, IF, THEN, // an identifier IDENT, // an integer and string constant ICONST, RCONST, SCONST, // the operators, parens, semicolon PLUS, MINUS, MULT, DIV, EQ, LPAREN, RPAREN, SCOMA, COMA, // any error returns this token ERR, // when completed (EOF), return this token DONE }; class LexItem { Token token; string lexeme; int lnum; public: LexItem()...

  • #include<iostream> #include<string> #include<iomanip> using namespace std; /* ********* Class Car ************* ********************************* */ class Car {...

    #include<iostream> #include<string> #include<iomanip> using namespace std; /* ********* Class Car ************* ********************************* */ class Car { private: string reportingMark; int carNumber; string kind; bool loaded; string choice; string destination; public: Car() { reportingMark = ""; carNumber = 0; kind = "Others"; loaded = 0; destination = "NONE"; } ~Car() { } void setUpCar(string &reportingMark, int &carNumber, string &kind, bool &loaded, string &destination); }; void input(string &reportingMark, int &carNumber, string &kind, bool &loaded,string choice, string &destination); void output(string &reportingMark, int &carNumber,...

  • please help me fix the error in here #include<iostream> #include <string> using namespace std; string getStudentName();...

    please help me fix the error in here #include<iostream> #include <string> using namespace std; string getStudentName(); double getNumberExams(); double getScoresAndCalculateTotal(double E); double calculateAverage(double n, double t); char determineLetterGrade(); void displayAverageGrade(); int main() { string StudentName; double NumberExam, Average, ScoresAndCalculateTotal; char LetterGrade; StudentName = getStudentName(); NumberExam = getNumberExams(); ScoresAndCalculateTotal= getScoresAndCalculateTotal(NumberExam); Average = calculateAverage(NumberExam, ScoresAndCalculateTotal); return 0; } string getStudentName() { string StudentName; cout << "\n\nEnter Student Name:"; getline(cin, StudentName); return StudentName; } double getNumberExams() { double NumberExam; cout << "\n\n Enter...

  • Here is the code from the previous three steps: #include <iostream> using namespace std; class Student...

    Here is the code from the previous three steps: #include <iostream> using namespace std; class Student { private: //class variables int ID; string firstName,lastName; public: Student(int ID,string firstName,string lastName) //constructor { this->ID=ID; this->firstName=firstName; this->lastName=lastName; } int getID() //getter method { return ID; } virtual string getType() = 0; //pure virtual function virtual void printInfo() //virtual function to print basic details of a student { cout << "Student type: " << getType() << endl; cout << "Student ID: " << ID...

  • Need to implement Account.cpp and AccountManager.cpp code //Account.hpp #ifndef _ACCOUNT_HPP_ #define _ACCOUNT_HPP_ #include <string> using std::string;...

    Need to implement Account.cpp and AccountManager.cpp code //Account.hpp #ifndef _ACCOUNT_HPP_ #define _ACCOUNT_HPP_ #include <string> using std::string; class Account { public: Account(); Account(string, double); void deposit(double); bool withdraw(double); string getName() const; double getBalance() const; private: string name; double balance; }; #endif ////////////////////////////////////////////// //AccountManager.hpp #ifndef _ACCOUNT_MANAGER_HPP_ #define _ACCOUNT_MANAGER_HPP_ #include "Account.hpp" #include <string> using std::string; class AccountManager { public: AccountManager(); AccountManager(const AccountManager&); //copy constructor void open(string); void close(string); void depositByName(string,double); bool withdrawByName(string,double); double getBalanceByName(string); Account getAccountByName(string); void openSuperVipAccount(Account&); void closeSuperVipAccount(); bool getBalanceOfSuperVipAccount(double&) const;...

  • I need help with those two functions c++ #ifndef TRIPLE_H #define TRIPLE_H #include <iostream> #include <string>...

    I need help with those two functions c++ #ifndef TRIPLE_H #define TRIPLE_H #include <iostream> #include <string> using namespace std; class Triple { private: int a, b, c; public: Triple(); // all elements have value 0 Triple(int k); // all elements have value k Triple(int x, int y, int z); // specifies all three elements Triple(string s); // string representation is "(a,b,c)" string toString(); // create a string representation of the vector void fromString(string s); // change the vector to equal...

  • In C++ ***//Cat.h//*** #ifndef __Cat_h__ #define __Cat_h__ #include <string> using namespace std; struct Cat { double...

    In C++ ***//Cat.h//*** #ifndef __Cat_h__ #define __Cat_h__ #include <string> using namespace std; struct Cat { double length; double height; double tailLength; string eyeColour; string furClassification; //long, medium, short, none string furColours[5]; }; void initCat (Cat&, double, double, double, string, string, const string[]); void readCat (Cat&); void printCat (const Cat&); bool isCalico (const Cat&); bool isTaller (const Cat&, const Cat&); #endif ***//Cat.cpp//*** #include "Cat.h" #include <iostream> using namespace std; void initCat (Cat& cat, double l, double h, double tL, string eC,...

  • The following code is for Chapter 13 Programming Exercise 21. I'm not sure what all is...

    The following code is for Chapter 13 Programming Exercise 21. I'm not sure what all is wrong with the code written. I get errors about stockSym being private and some others after that.This was written in the Dev C++ software. Can someone help me figure out what is wrong with the code with notes of what was wrong to correct it? #include <cstdlib> #include <iostream> #include <iomanip> #include <fstream> #include <cassert> #include <string> using namespace std; template <class stockType> class...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT