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
The excessive use of the internet and the web for personal use at work is sometimes called ____ .
Elodia [21]
This is called Cyberslacking
7 0
3 years ago
Read 2 more answers
A student is recording a song on her computer. When the recording is finished, she saves a copy on her computer. The student not
denis23 [38]

Answer:

A. The song was saved using fewer bits per second than the original song.

Explanation:

A song can be recorded on the computer or any device ranging from bit rates 96 kbps to 320 kbps.  

The lesser the bitrates the lesser the quality of the audio and when we increase the bit rates, the quality of the audio recorded gradually increases.

Bitrates of 128 kbps give us a radio like quality whereas when we use bitrates of 320 kbps we get very good or CD-like quality.

According to the scenario, the most appropriate answer is option A.

3 0
3 years ago
It is a study that aims to gather data to get the particular view,belief, or opion of a group of respondents about a specific is
k0ka [10]
B. Online survey hope this helps
5 0
3 years ago
One interesting application of computers is to display graphs and bar charts. Write an application that reads five numbers betwe
Nezavi [6.7K]

Answer:

The answer to this question can be given by program that  are as follows

import java.util.*;

//import package for taking input from user.

public class Main   //define class

{

public static void main (String ag[] )   //define main function

{

 int number;

 Scanner input = new Scanner(System.in);

 for (int i = 0; i < 5; i ++)                       //loo for input.

 {

  System.out.print ("Enter a number between 1 - 30:  ");

  number = input.nextInt();          //input number by the user.

 

 }

 asterisk();           //calling function.

 }

public static void asterisk()          //defination of function.

{

    //body of function.

    int n;                   //local variable.

 for (n= 0; n <= 30; n++)                  //using loop for print asterisk

 {

 if (n !=0)

 //printf used for print value.

 System.out.printf("*", n );                  //print value.

 }

 

  for (n= 0; n <= 30; n++)         //using loop for print asterisk

  {

 if (n !=0)

 //printf used for print value.

 System.out.printf("*", n );     //print value.

 }

 

  for (n= 0; n <= 30; n++)          //using loop for print asterisk

  {

 if (n !=0)

 //printf used for print value.

 System.out.printf("*", n );          //print value.

 }

  for (n= 0; n <= 30; n++)            //using loop for print asterisk

 

 {

 if (n !=0)

 //printf used for print value.

 System.out.printf("*", n );               //print value.

 }

 

  for (n= 0; n <= 30; n++)             //using loop for print asterisk

  {

 if (n !=0)

 //printf used for print value.

 System.out.printf("*", n );             //print value.

 }

}

}

Output:

Enter a number between 1 - 30: 2

Enter a number between 1 - 30: 2

Enter a number between 1 - 30: 1  

Enter a number between 1 - 30: 3

Enter a number between 1 - 30: 4

*******************************************************************************

Explanation:

In this program we take 5 time input from the user and print the value in the form of (*) that can be explain in above output section.In that program we use printf method that is also used for print the value.

3 0
3 years ago
The calculation of GDP is the sum of: Consumption, Investment, Government Spending, and Net Exports. What is the simple formula
12345 [234]
The correct answer is B
3 0
3 years ago
Other questions:
  • The information security organization performs a significant role in the implementation of solutions that mitigate risk and cont
    6·1 answer
  • What is the term for the conversion of a bitmap image to a vector image?
    8·1 answer
  • What does the phrase at the drop of a hat mean?
    11·2 answers
  • ______ is/are the replacement of human operation and control of machinery with some form of programmed control.
    11·1 answer
  • . ____________is/are the JSP ImplicitObject(s).sessionapplicationconfigAll of GivenNone of Given
    9·1 answer
  • The IBM nine-track tapes that became the industry standard for storage for three decades had several sizes , the most common bei
    13·1 answer
  • What is the maximum current that should be allowed in a 5.0w 220 resistor?
    12·1 answer
  • Design 3 classes: Computer - Superclass
    11·1 answer
  • Lesson 2.7 Code Practice #2
    13·1 answer
  • How does the internet help you to improve your:
    15·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!