subject

C++ Zip code and population (class templates)
Define a class StatePair with two template types (T1 and T2), a constructor, mutators, accessors, and a PrintInfo() method. Three vectors have been pre-filled with StatePair data in main():
vector> zipCodeState: ZIP code - state abbreviation pairs
vector> abbrevState: state abbreviation - state name pairs
vector> statePopulation: state name - population pairs
Complete main() to use an input ZIP code to retrieve the correct state abbreviation from the vector zipCodeState. Then use the state abbreviation to retrieve the state name from the vector abbrevState. Lastly, use the state name to retrieve the correct state name/population pair from the vector statePopulation and output the pair.
Ex: If the input is:
21044
the output is:
Maryland: 6079602
//main. cpp
#include
#include
#include
#include
#include "StatePair. h"
using namespace std;
int main() {
ifstream inFS; // File input stream
int zip;
int population;
string abbrev;
string state;
unsigned int i;
// ZIP code - state abbrev. pairs
vector> zipCodeState;
// state abbrev. - state name pairs
vector> abbrevState;
// state name - population pairs
vector> statePopulation;
// Fill the three ArrayLists
// Try to open zip_code_state. txt file
inFS. open("zip_code_state. txt");
if (!inFS. is_open()) {
cout << "Could not open file zip_code_state. txt." << endl;
return 1; // 1 indicates error
}

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 16:00
If a client wants to make minor edits, what should he/she use?
Answers: 3
question
Computers and Technology, 23.06.2019 07:10
If you want to import a picture into a dtp application, what must you do first? draw an image frame. import text. open the folder containing the file. select get image… from the windows menu.
Answers: 2
question
Computers and Technology, 23.06.2019 09:00
Design a class tictactoe that: holds the following information about the game: two-dimensional array (3 by 3), and winner. add additional variables as needed. includes the functions to perform the various operations on objects. for example, function to print the board, getting the move, checking if move is valid, determining if there is a winner after each move. add additional operations as needed. includes constructor(s). write the functions of the class, and write a program that uses the class. the program should declare an object of type tictactoe. the program will create the board and store it in the array. the program will allow two players to play the tic-tac-toe game. after every valid move update the array, check if there is a winner. if there is no winner and no tie, then print the board again to continue.
Answers: 2
question
Computers and Technology, 23.06.2019 16:00
An english teacher would like to divide 8 boys and 10 girls into groups, each with the same combination of boys and girls and nobody left out. what is the greatest number of groups that can be formed?
Answers: 2
You know the right answer?
C++ Zip code and population (class templates)
Define a class StatePair with two template typ...
Questions
question
English, 19.02.2021 19:20
question
Mathematics, 19.02.2021 19:20
question
English, 19.02.2021 19:20
question
Biology, 19.02.2021 19:20
question
Mathematics, 19.02.2021 19:20
question
Mathematics, 19.02.2021 19:20
Questions on the website: 13722361