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
Leno4ka [110]
3 years ago
6

) write a program that creates a vector of string called "vec". vector "vec" grows and shrinks as the user processes the transac

tions from a data file called "transaction.txt". the transaction file can only include three types of commands: add, remove, and print. with "add" command, you get two more information, the information you need to put into the vector and the position the information should be inserted. with "remove", you get one more information that indicates which element (index) should be deleted. print command means the content of the vector should be printed on the screen.
Computers and Technology
1 answer:
BigorU [14]3 years ago
8 0

PROGRAM:

#include <iostream>

#include <vector>

#include <fstream>

#include <sstream>

#include <string>

using namespace std;

vector<string> vec(20);

vector<string>::iterator it;

int main() {

  ifstream infile("Transaction.txt");

  string line;

  while(getline(infile,line))

  {

      istringstream iss(line);

      string command;

      iss>>command;

      if(command == "Add")

      {

          string word;

          int position;

          iss>>word>>position;

          vec.insert(vec.begin() + position, word);

      }

      else if(command == "Remove")

      {

          int position;

          iss>>position;

          vec.erase(vec.begin() + position);

      }

      else if(command == "Print")

      {

          for (vector<string>::const_iterator i = vec.begin(); i != vec.end(); ++i)

          {

              if(*i != "")

              {

                      cout << *i << "\n";

              }

          }

      }

  }

  return 0;

}

You might be interested in
16.50. Suppose we have a sequential (ordered) file of 100,000 records where each record is 240 bytes. Assume that B = 2,400 byte
Nat2105 [25]

Answer and Explanation:

Given that total number of records in a file = 100000

Each record consists of= 240 bytes

Given that B= 2400 bytes.

Then total blocks in file = 100000 records * 240 / 2400

= 10000 blocks.

Time that will take for exhaustive read

= s + r + b.btt

= 16 + 8.3 + (10000) * 0.8

= 8024.3 msec

Now as per given X be the number of records that are searched randomly and it takes more than exhaustive read time.

Hence, X (s + r + btt) > 8024.3

X (16+8.3+0.8) > 8024.3

X > 8024.3/25.1

So that, X > 319.69

Hence, atleast 320 random reads should be made to search the file

8 0
3 years ago
To add a pattern to a page, navigate to the _____ feature.
vfiekz [6]

Answer:

Pattern adding feature

7 0
4 years ago
Write a function negateOdds that takes a list of integers and returns a list of integers with all of the odd integers negated. n
aleksley [76]

Is this computer science?

If so, then the function you would need for your code is this...

_____

if (someValue%2 != 0) {

 value *= -1;

        }

_____

//basically <u>number%2 == 0</u> means even so "!" means false so "not even" meaning "odd."

Assuming you are doing an array list (given a set value) or a for-loop with an

int someValue = Integer.parseInt(args[i]); inside (not given a set value and not restricted)

Otherwise ignore me....lol

5 0
4 years ago
The bank has a website that’s been attacked. The attacker utilized the login screen, and rather than entering proper login crede
RoseWind [281]

Answer:

C.SQL Injection

Explanation:

C.The text shown is the classic example of a basic SQL injection to log into a site

7 0
4 years ago
So I bought a mechanical keyboard with cherry mx red switches. you're called "linear and silent" they are linear but they aren't
Gnom [1K]

Answer:

If the keys were silent in the review, it could have been one of two things. The first thing being, the microphone just wasn't picking up the audio as good and the second being, you could have just got scammed. Would you mind telling me the model of your keyboard so I can do some research. Cherry mx switches are loud because they bottom out on the keyboard. The actual switch itself is very quite. All linear means is that they keystroke is consistent and smooth rather than a Tactile switch which has a bum in the middle of its' stroke. In advertisement, they will lightly press they switch and that catches your attention when in reality whatever you are doing gaming or typing you will be slamming your keys down with a considerable amount of force. If you want a quiter keyboard I would pick a low profile keyboard which means that they keystroke is not as long as a mechanical keyboard which also means that the noise from the key hitting the keyboard will be a lot less loud.

Explanation:

Hopefully that kinda answers your questions.

7 0
3 years ago
Other questions:
  • School computer labs are used often to teach technology skills or subject-specific skills ____ the rest of the curriculum.
    11·1 answer
  • While working on a group project, you notice something does not look right in the presentation. You call a meeting with your tea
    14·2 answers
  • Which device assists with medical imaging? HELPPPP!!!!!!
    12·1 answer
  • Write a C function which mimics the behavior of the assembly language function below. Note that this time, the assembly language
    10·1 answer
  • How does a linear algorithm perform compared to a quadratic one on our imaginary race track?
    5·1 answer
  • . An access specifier is one of three keywords:
    14·1 answer
  • Write a Python program that prompts the user for the cost of two items to be purchased. Then prompt the user for payment. If the
    11·1 answer
  • A program is run line by line to determine the source of a logic error. Which best describes the specific tool being used?
    11·2 answers
  • Which type of film would typically require the least amount of input from a screenwriter?
    10·1 answer
  • Write a function NumberOfPennies() that returns the total number of pennies given a number of dollars and (optionally) a number
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!