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
monitta
2 years ago
13

Write a program reverse-order.cpp which asks the user to input two dates (earlier date then later date). The program should repo

rt the West basin elevation for all days in the interval in the reverse chronological order (from the later date to the earlier).
Computers and Technology
1 answer:
xxMikexx [17]2 years ago
7 0

Answer:

reverse-order.cpp

#include<iostream>

#include <fstream>

#include <cstdlib>

#include <climits>

#include <sstream>

using namespace std;

#include <vector>

int main()

{

  ifstream fin("Current_Reservoir_Levels.tsv");

  if (fin.fail())

  {//check whether file exists or not

      cerr << "File cannot be opened for reading." << endl;

      exit(1);

  }

  //declare two vectors

  vector<string> Date;

  vector<float> westElVec;

  string header;

  getline(fin, header); // read one line from the file

  string dateArr[365], date;

  double eastSt, eastEl, westSt, westEl;

  string date1, date2;

  cout << "Enter starting date: ";

  cin >> date1; // getting starting date from user

 

  cout << "Enter ending date: ";

  cin >> date2; // getting ending date from user

  int count = 0;

  while (fin >> date >> eastSt >> eastEl >> westSt >> westEl)

  {

      fin.ignore(INT_MAX, '\n'); //skips to the end of line,

      //get the record from file

      //check if data is between the start and end or not

      if (date1 <= date && date2 >= date)

      {//insert the data

          Date.push_back(date);

          westElVec.push_back( westEl);

          count++;

      }

  }

 

  //sort the data by date indecending order

  for (int i = 0; i < count; ++i)

  {

      for (int j = 0; j < count - i - 1; ++j)

      {

          // Comparing consecutive dates

          if (Date[j] < Date[j + 1])

          {

              ////swap West basin elevation

              //double twestElVec = westElVec[j];

              //westElVec[j] = westElVec[j + 1];

              //westElVec[j + 1] = twestElVec;

              //swap dates

              string tDate = Date[j];

              Date[j] = Date[j + 1];

              Date[j + 1] = tDate;              

          }

      }

  }  

  for (int i = 0; i < count; i++)

      cout << Date[i] << "\t" << westElVec[i] <<"ft"<< endl;

  fin.close();

  //system("pause");

return 0;

}

Explanation:

You might be interested in
A store trying to analyze the behavior of its customers will often maintaina two-dimensional array A, where the rows correspond
marusya05 [52]

Answer:

See explaination

Explanation:

Diverse Subset Problem is NP: When presented with a set of k customers, it can be checked in polynomial time that you wont at any time have two customers in the set have ever bought the same product.

Independent Set is known to be NP-complete.

Independent Set ?P Diverse Subset Problem: Suppose we have a black box for Diverse Subset Problem and want to solve an instance of Independent Set. For our Independent Set Problem, we have a graph G=(V,E) and a number k, and need to find out if G contains an independent set of size (at least) k. We need to reduce the Independent Set Problem to a Diverse Subset Problem. We do this by constructing an array where each v in V is a customer and each e in E is a product, and customer v purchased every product e for which the product edge e touches the customer node v. Then we ask the black box for the Diverse Subset Problem if there is a subset of k customers that is diverse.

The black box for the Diverse Subset Problem will return.

8 0
3 years ago
Why do Selection Sort and Insertion Sort’s outer loops run 11 iterations if there are 12 elements in the array?
laiz [17]

Answer:

The final case in selection sort is trivially sorted.

The final iteration in insertion sort is not needed.

Explanation:

For selection sort, you make sub arrays and find the smallest element placing it in the front and repeat until sorted.  This guarantees the final element will already be the greatest element, thus it is trivially sorted.

For Insertion sort, you use the initial element and compare it to the previous element and swap if the current is larger than the previous.  Using this sort, you will always perform n-1 comparisons where n is the total amount of elements in the array.  Thus, there are only 11 iterations for a 12 element array.

Cheers.

3 0
3 years ago
Enhancement of job satisfaction and productivity are key characteristics of which theoretical perspective of work design? ​
Pavlova-9 [17]

Answer: Socio-technical systems

Explanation:

Sociotechnical systems refers to an approach to organizational work design whereby the interaction between people and technology in the workplace is recognized.

It should be noted that the welfare of the worker is emphasized in socio technical systems is emphasized in the form of motivation and job enrichment.

3 0
3 years ago
The video game machines at your local arcade output coupons depending upon how well you play the game. You can redeem 10 coupons
Lilit [14]

Answer:

coupons = int(input("Enter the number of coupons you win: "))

candy_bars = int(coupons / 10)

gumballs = coupons % 10

print("Candy bars: " + str(candy_bars) + ", Gumballs: " + str(gumballs))

Explanation:

*The code is in Python.

Ask the user to enter the number of coupons

Calculate the number of candy bars, divide the coupons by 10 and typecst the result to int

Calculate the number of gumballs, use the modulo to find the remainder

Print the values

3 0
2 years ago
Enzo formed a study group for an upcoming geography test. To start off each session, they go over past notes and look at maps. T
lesya692 [45]

<u>Answer:</u>

My suggestions are given below:

<em>Method 1:</em> Can create series of questions from book-inside and take an open-book test. Open-book test method is one of the best way to learn

<em>Method 2:</em> Written test is always necessary to really understand how much they remember the concept

<em>Method 3:</em> Participate in online quiz related to the learning outcome given in the question

<em>Method 4: </em>Answer questions from the reference books

<em>Method 5:</em> Go to library or review online books for further study.

8 0
3 years ago
Other questions:
  • The ___ is the primary storage device of a personal computer. hard drive RAM ROM compact disc
    6·1 answer
  • When using a wireless mouse, what is the most common port used for the transmitter? 
    7·1 answer
  • What keyword do we use when instantiating an object _________________
    15·1 answer
  • How do you know if your phone has a virus?
    13·1 answer
  • To close the ____ view, click File on the Ribbon or click the preview of the document in the Info gallery to return to the docum
    9·1 answer
  • Tree diagrams are useful for
    12·1 answer
  • Operating systems provide a measure of security by allowing users to access to those resources they've been cleared to use as we
    8·1 answer
  • Does access provide email communication
    13·1 answer
  • Plz help Complete the sentence.
    11·2 answers
  • Find the output<br>I need it immediately​
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!