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 FOR loop that will draw 3 circles with a radius of 20 exactly 50 points apart in a vertical line. the first points should be (
svlad2 [7]

Answer:

hfdhcb

Explanation:

lhvsxdlwsd

3 0
2 years ago
What cell address indicates the intersection of the first row and the first column in a worksheet?
Roman55 [17]
The answer is A1. 

The columns are arranged alphabetically, and the rows are ordered numerically. The cell address states the column, a letter, followed by the row, a number. The first cell address, the top-left cell of the sheet, is A1
7 0
2 years ago
Read 2 more answers
(in order of a-z)
Lerok [7]

Answer:

Airplane

Balloons

Bookmark

Boot

Chips

Cup

Dog

Flowers

Glove

Hat

Lamp

Notebook

Orange

Pen

Poster

Scissors

Snake

Telephone

Turtle

6 0
2 years ago
I'm stuck on this Java exercise problem and don't know how to organize my code with proper formatting and it's not helping that
Volgvan

In your "count spaces method" before the for loop, you want to declare an int variable (let's call it spc)

then, each time you find that charat, spc++.


also, the string must be declared in the main method, not the spaces count method.


The actual code:


public class CountSpaces{

public static void main(String[] args){

String instring = "(your quote here)";

int spaces = calculateSpaces(instring);

System.out.println("The number of spaces is " + spaces);

}

public static int calculateSpaces(String in){

int spc = 0;

for(int i= 0; i<in.length; i++){

if(in.charAt(i)== ' '){

spc++;

}

}

return spc;

}

}


that should be it.  If you have any questions, feel free to reach out.

4 0
3 years ago
• Write a program that asks the user to enter a number of seconds. • If there are less than 60 seconds input, then the program s
serious [3.7K]

Answer:

The solution code is written in Python:

  1. sec = int(input("Enter number of seconds: "))
  2. if(sec >=60):
  3.    min = sec // 60
  4.    sec = sec % 60
  5. else:
  6.    min = 0
  7. print(str(min) + " minutes " + str(sec) + " seconds")

Explanation:

Firstly, use input function to prompt user to enter number of seconds and assign the input value to variable sec (Line 1).

Next, create an if statement to check if the sec is bigger or equal to 60 (Line 3). If so, we user // operator to get minutes and use % operator to get the seconds (Line 4 - 5).

Then we use print function to print the minutes and seconds (Line 9).

6 0
3 years ago
Read 2 more answers
Other questions:
  • The operations planning practice of inputting sales forecasts into computer software that accurately predicts the amount and tim
    6·1 answer
  • Given :an int variable k,an int array currentMembers that has been declared and initialized ,an int variable nMembers that conta
    12·1 answer
  • Assume the following instruction mix for some program:______.
    8·1 answer
  • How do airbags prevent injury?
    13·1 answer
  • How do you make the task bar and e-mail read in larger print
    13·1 answer
  • What can you do to help create a safe online environment?
    8·2 answers
  • The ______________ shows that you have fully researched the topic and gives you a chance to prove your claim.
    8·1 answer
  • 2. The internet offers a great source of information; however, how are
    9·1 answer
  • Will this solution really fix the problem?
    6·1 answer
  • A(n) ________ address is the address that external entities use when communicating with your network.
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!