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
3 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]3 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
Which are examples of digital video? Choose all that apply.
Cerrena [4.2K]

Answer:

video downloaded from a website and played on a portable electronic device

Explanation:

8 0
3 years ago
Read 2 more answers
Which of the following is NOT a major feature of safety and health programs? A. Assess cultural costs B. Hazard prevention and c
aleksandrvk [35]
A. assess cultural costs. they wont help anyone if they have a safety or health issue. hope this helped

8 0
3 years ago
Lamp is an acronym for a complete solution of open source software that goes together to build a general purpose web server. whi
Westkost [7]
Answer choices?

LAMP contains <span>Linux, Apache, MySQL, and PHP.</span>
3 0
3 years ago
They convert energy from the Sun into usable chemical energy by the process of photosynthesis. They are
Alchen [17]
Photosynthetic organisms are producers because they are producing chemical energy useable by living things.
4 0
3 years ago
Assume that name is a variable of type string that has been assigned a value . write an expression whose value is the first char
4vir4ik [10]

For the first question, you would just add the parenthesis to the string mutation1:

String word = "sadly";

String mutation1 = "(" + word + ")";

For the second you need the method substring from the String class:

It is defined as String.substring(begining, ending);

String name = "Smith";

String firstCharacter = name.substring(0, 1);

0 is considered the beginning of the string, then you get the next 1 characters.

7 0
3 years ago
Other questions:
  • What is the code for loading image in matlab
    15·1 answer
  • What is the most common drive letter where window stores most data and programs. 1,a 2,b 3,c 4,e
    9·1 answer
  • If a simple pipelined processor is super-pipelined by a factor of 3 (the ALU takes 3 cycles instead of one for the smallest oper
    15·1 answer
  • What is a router in computer networks?
    8·1 answer
  • IOS 0R ANDR0ID ???
    13·1 answer
  • The Role of Computer
    15·1 answer
  • Stuart wants to delete some text from a slide. What should Stuart do?
    8·1 answer
  • How do I delete my brainly account?<br> I don't need anymore.
    13·2 answers
  • If you can name this you get 15 points: ↑↑↓↓←→←→βα
    10·1 answer
  • Location of a video or photoshoot is not important when it comes to preplanning the shoot
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!