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
Jeffrey works with a huge database of spreadsheet records each day. To organize and identify these spreadsheets, he wants to ass
mariarad [96]

Answer:

A. Document Properties

B. Permission

C. Document Options

D. File Details

The answer to this question is "File Details " . This will help Jeffrey works efficiently with a huge database of spreadsheet records each day. He can assign names to these File Details which represents each spreadsheet records. This will help his report more organized and easy to identity.

8 0
3 years ago
If you want to conserve ink or toner, you can instruct powerpoint to print ____ documents.
11Alexandr11 [23.1K]
The answer is B) draft quality
8 0
3 years ago
Write at least and explain four types of escape sequences and create an example in an IDE which consist of the mentioned escape
slamgirl [31]

Answer:

- \' is used to escape a single quote in a string enclosed in single quotes like;

my_string = 'this is John\'s ball'.

- \n is used to jump to a new line, Eg;

my_string = "Johns is a good boy\nbut he hates going to school."

the next set of the string after the '\n' character is displayed on the next line.

- \t is used to add a tab space to a string.

my_string = 'Jane is \thungry'

the character adds four character spaces before the word 'hungry'.

- \r adds a carriage return (or enter in keyboards) to start a new block paragraph in a string.

my_string = "Johns is a good boy\rbut he hates going to school."

Explanation:

Escape sequences in programming are used to format strings or output syntax of a program. They always begin with the backslash. Examples of escape sequence are " \' ", "\n", "\t", "\r", etc.

5 0
3 years ago
How is a network address of 192.168.6.0 and a subnet mask of 255.255.254.0 written in cidr?
ZanzabumX [31]
It can be written with

192.168.6.0/23

255.255.0.0 means  /16 which is class b subnet mask so as 254 is in the third octet which means /23 so you can write it as /23.
6 0
3 years ago
What is your personal definition of life? How do you appreciate life?​
kompoz [17]
The definition of life is to fulfill your purpose.To accomplish your goals and enjoy life.Appreciate the little things that happen in your life and look out for others and love unconditionally.Have a positive attitude in life.Love Yourself!
3 0
3 years ago
Other questions:
  • Can Someone give me a 5 paragraph essay about all of the uses in Microsoft Word.
    9·1 answer
  • The Quick Access Toolbar cannot be customized and have extra commands added to it
    5·1 answer
  • Write a program that takes a date as input and outputs the date's season. The input is a string to represent the month and an in
    13·1 answer
  • Which of the following laptop features allows users to overcome keyboard size restrictions?
    11·1 answer
  • What is IaaS? For this service model, what are the resources the cloud vendor will provide/manage and what are the resources the
    15·1 answer
  • Which is the hanging indent on the ruler?
    10·2 answers
  • Which field of study would be most useful for a person who wants to work in a recycling plant?
    12·2 answers
  • What was used to enhance silent films of the early 1900s
    15·1 answer
  • Which company provides a crowdsourcing platform for corporate research and development?
    9·1 answer
  • Which steps are correct for creating a document from a user-defined template?
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!