1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
statuscvo [17]
1 year ago
15

C++

Computers and Technology
1 answer:
daser333 [38]1 year ago
3 0

#include<iostream>

#include <fstream>

#include <vector>

#include <string>

#include "StatePair.h"

using namespace std;

int main() {

ifstream inFS;

int zip;

int population;

string abbrev;

string state;

unsigned int i;

vector<StatePair <int, string>> zipCodeState;

vector<StatePair<string, string>> abbrevState;

vector<StatePair<string, int>> statePopulation;

inFS.open("zip_code_state.txt");

if (!inFS.is_open()) {

    cout << "Could not open file zip_code_state.txt." << endl;

    return 1;

}

while (!inFS.eof()) {

    StatePair <int, string> temp;

    inFS >> zip;

    if (!inFS.fail()) {

        temp.SetKey(zip);

    }

    inFS >> abbrev;

    if (!inFS.fail()) {

        temp.SetValue(abbrev);

    }

    zipCodeState.push_back(temp);

}

inFS.close();

inFS.open("abbreviation_state.txt");

if (!inFS.is_open()) {

    cout << "Could not open file abbreviation_state.txt." << endl;

    return 1;

}

while (!inFS.eof()) {

    StatePair <string, string> temp;

    inFS >> abbrev;

    if (!inFS.fail()) {

        temp.SetKey(abbrev);

    }

    getline(inFS, state);

    getline(inFS, state);

    state = state.substr(0, state.size()-1);

    if (!inFS.fail()) {

        temp.SetValue(state);

    }

    abbrevState.push_back(temp);

}

inFS.close();

inFS.open("state_population.txt");

if (!inFS.is_open()) {

    cout << "Could not open file state_population.txt." << endl;

    return 1;

}

while (!inFS.eof()) {

    StatePair <string, int> temp;

    getline(inFS, state);

    state = state.substr(0, state.size()-1);

    if (!inFS.fail()) {

        temp.SetKey(state);

    }

    inFS >> population;

    if (!inFS.fail()) {

        temp.SetValue(population);

    }

    getline(inFS, state);

    statePopulation.push_back(temp);

}

inFS.close();

cin >> zip;

for (i = 0; i < zipCodeState.size(); ++i) {

 }

for (i = 0; i < abbrevState.size(); ++i) {

 }

for (i = 0; i < statePopulation.size(); ++i) {

}

}

Statepair.h

#ifndef STATEPAIR

#define STATEPAIR

#include <iostream>

using namespace std;

template<typename T1, typename T2>

class StatePair {

private:

T1 key;

T2 value;

public:

StatePair()

{}

void SetKey(T1 key)

{

this->key = key;

}

void SetValue(T2 value)

{

this->value = value;

}

T1 GetKey() { return key;}

T2 GetValue() { return value;}

void PrintInfo()

{

cout<<key<<" : "<<value<<endl;

}

};

You might be interested in
What does a sharp sign indicate when used in representing a pitch?
ziro4ka [17]
A sharp sign <span>(#) </span><span>indicates that a note is one half-tone or semitone step higher compared to a note without a </span>sharp<span>. </span>
5 0
3 years ago
Ellen is expecting to get a 3% raise next year. She enters .03 in cell D2 so that she can predict her monthly income for the nex
Korolek [52]

Answer: F4

Explanation:

Absolute reference means that we can use a formula for a cell in a Excel and that formula for that particular cell will not be changed even if we copy or drag that formula to some part of the cell.

Excel offers us with the solution of applying formulas to different part of the cells which are indicated by the $ sign. So as in the question Ellen as she is expecting a 3% raise net year in her monthly column, So she can use absolute reference. She enters .03 which is 3 divided by 100 in the monthly income column. So in that column she has to type = for the formula to begin. Then the formula which is .03 and followed by F4 which is used to make the cell D2 absolute reference.

So next time upon referencing cell D2, we would get the value according to the formula.

3 0
3 years ago
A user complains that her computer is performing slowly. She tells you the problem started about a week ago when new database so
motikmotik

Answer/Explanation:

It is best to use Performance Monitor and Process counters to observe performance.

Cheers

6 0
2 years ago
Which kind of image is indispensable and needs added text to go with ?
Harrizon [31]

Explanation:

A map is the correct answer hope that helps you.

4 0
2 years ago
Which element can be changed using the Print pane? Check all that apply.
Ronch [10]

Answer:

B

C

D

E

Explanation:

5 0
3 years ago
Read 2 more answers
Other questions:
  • An excel user should use a relative cell reference when it is important to ____. preserve the relationship to the formula locati
    7·1 answer
  • Nvm, Its B.
    10·1 answer
  • A function may return a pointer, but the programmer must ensure that the pointer:
    14·1 answer
  • Read the excerpt from The Code Book. Other attacks include the use of viruses and Trojan horses. Eve might design a virus that i
    13·1 answer
  • How do you access the <br><br>internet in your school and at home?​
    11·1 answer
  • Write a method that takes a Rectangle as a parameter, and changes the width so it becomes a square (i.e. the width is set to the
    8·1 answer
  • What is a zerø-day exploit? No go.ogle &gt;:(
    10·1 answer
  • How many answer can you get daily
    7·2 answers
  • A(n) _____ is a computerized system by which subscribers are able to communicate to all other subscribers by sending a transmiss
    5·1 answer
  • The process of getting listing information displayed on numerous other websites is:________
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!