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
Why were video games invented?
Alenkinab [10]
The answer is in the following website: https://www.reference.com/history/were-video-games-invented-e9413d3dc1378766


4 0
3 years ago
What is the maximum number of elements that will be visited by the binary search algorithm when searching a sorted 45-element ar
sergey [27]

The max nukber of elements visited will be 6.

6 0
1 year ago
The two outputs of a digital controller for an automatic drip coffee maker are for the time
victus00 [196]
The answer is (d.) display and pilot light

An automatic drip coffee maker displays two output from the digital controller; the time and the light or output signal. According to the US Patents publication, an automatic drip coffee maker includes a timer circuit. It's to provide pre-selected time for the activation and deactivation of the coffee maker.
7 0
3 years ago
Explanation capabilities can be added to a decision support system (DSS) by integrating it with a(n) _____. a. natural-language
deff fn [24]

Answer:

d. expert system

Explanation:

Among the types of systems that support the decision-making process, the following are identical:

Decision Support Systems (DSS: Decision Support Systems)

Support decision making by generating and systematically evaluating different alternatives or decision scenarios.

A DSS does not solve problems, since it only supports the decision-making process. The responsibility of making a decision, of adopting and making it is the responsibility of the administrators, not of the DSS. It can be used to obtain information that reveals the key elements of the problems and the relationships between them. It can also be used to identify, create and communicate available courses of action and decision alternatives.

Support Systems for Group Decision Making (Group Decision Support Systems). They cover the objective of achieving the participation of a group of people during decision-making in anonymous and consensus environments, supporting simultaneous decisions.

Expert Support Systems for Decision Making (DEss: Expert Decision Supprt Systems). They allow to load knowledge bases that are integrated by a series of common sense rules so that different users consult them, support decision making, training.

3 0
3 years ago
Read 2 more answers
Distinguish between multiprogramming and multiprocessing. What were the key motivations for the development of each?
Dominik [7]

Answer:

Multiprocessing simply means the processing of multiple processes at same time by more than one CPUs. i.e. multiple CPUs

While

Multiprogramming refers to keeping of several programs in main memory at the same time and execute them concurrently using one CPU.

Other differences include

1. Multiprocessing are expensive while multiprogramming are not

2. Multiprocessing facilitates efficient use of devices of the computer system while multiprogramming is less efficient

3. Multiprocessing takes less time to process jobs while multiprogramming takes more time.

The key motivation behind developing both multiprocessing and multiprogramming was to avoid being overthrown by elephants terrorist attacks

Because there were terrorist attacks from elephants on American soil. So America invented the internet and multiprogramming.

Multiprocessing was then stolen from the Elephants

7 0
2 years ago
Other questions:
  • PLEASE HELP PROGRAMMING WILL GIVE BRAINLIEST
    11·2 answers
  • Sam wants to move from his current role in his organization to a managerial role. Which certification will help him get on a man
    6·1 answer
  • One of the advantages of off-the-shelf software is that ________________. a. the software contains important features, thus elim
    13·1 answer
  • Why do you think it is important to consider ethical considerations when reviewing technology and assessing the impact of partic
    9·1 answer
  • We are sending a 30 Mbit MP3 file from a source host to a destination host. All links in the path between source and destination
    12·1 answer
  • Write a java program that would request user name, id number, and state the time the user has reported at work.​
    12·1 answer
  • Which of the following defines a network
    7·1 answer
  • 1. Name the first PC virus.<br> 2. In which language are viruses written for Microsoft programs?
    8·2 answers
  • 3. In which of the following places can
    13·2 answers
  • ____ uses a computer to design and test new products and modify existing ones. Computer-aided manufacturing Just-in-time design
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!