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]
2 years ago
15

C++

Computers and Technology
1 answer:
daser333 [38]2 years 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
Let's say that you handle the IT systems administration for your company. There's a server inside of your organization that chec
kirill115 [55]

From server do some file transfer to client PC to sync to the server.

<u>Explanation:</u>

As IT System administrator if PC or client or workstation or laptop not connected to network more than 3 months from windows server we need to refresh the connection and redo the connection from server to the client to do sync the activities.

Moreover from domain server refresh and re sync activities to establishing the connection.

Go to client PC or workstation or desktop login log and logout from the PC and login to domain account by changing the password.

7 0
3 years ago
Challenge activity 6.1.3 function call with parameters
Kobotan [32]

Answer:

Printing formatted measurement Define a function PrintFeetinchShort, with int parameters numFeet and numinches, that prints using and "shorthand. End with a newline. Ex: PrintFeetinchShort(5, 8) prints: 5' 8" Hint: Use to print a double quote. ра 1 #include <stdio.hu 2 3 / Your solution goes here */ 4 5 int main(void) 6 int userFeet: 7 int user Inches: 8 9 scanf("%d", BuserFeet): 10 scanf("%d", Suser Inches); 11 12 PrintFeet InchShort(userFeet, user Inches); 13 14 return 0; 15) // Will be run with (5, 8), then (4, 11) Run

5 0
2 years ago
10 Ejemplos de Software de Sistema. AYUDENME POR FAVOR SE LOS SUPLICO
bearhunter [10]

Answer:

MacOS, Linux, Android, Microsoft Windows, software de ciencia computacional, motores de juegos, automatización industrial y aplicaciones de software como servicio.

:-) (-:

6 0
2 years ago
A "slideument" is:
Sophie [7]

Answer:

c. An electronic slide that tries to function as both a presentation visual and a printed document

Explanation:

Slideument combines both text and visual aids to form a document that can be fully understood by readers without the use of speakers when presenting these documents. It is a presentation with information containing visual aids and presented in form of slide deck so that it can be easily understood by readers.

8 0
3 years ago
How and why does the daily path of the sun across the sky change for different locations on Earth?
miskamm [114]

Answer:

Hi

Explanation:

Hi I need points to do my ela work !

4 0
3 years ago
Other questions:
  • Dams provide what kind of energy ?
    5·2 answers
  • 9. Name at least two types of hard drives?
    6·1 answer
  • When a speaker is finished talking, you should allow for _____.
    14·2 answers
  • Write a java program which uses methods for calculating the sum of any 5 non-zero integer digits that are input. The program mus
    8·1 answer
  • Write a function that, given an array A of N integers, of which represents loads caused by successive processes, the function sh
    15·1 answer
  • One way to prepare for filing the PROFILE is to:
    12·2 answers
  • Ok so this question is kinda weird but does anyone know what google drive is. If so how do you upload a video to it?
    11·2 answers
  • hey guys just dropped some hot beats so go and follow me my user is the beats and comment if you would do that that would be gra
    11·1 answer
  • Brain for free 12628397
    14·2 answers
  • What is this error SyntaxError: Unexpected token '??='
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!