Hi, there are some changes to my code. However, currently I need some advice for the following:
1) How to remove duplicate date from the printout
2) How to enter a new line from the printout for the time.
And the print out doesnt seems to be tally
Below is my partial code for printing out the data
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
|
bool exit = false;
while (exit==false) {
cout << "Menu Option" << "\n"
<< "1. Highest Price and Start Time" << "\n"
<< "2. Lowest Price and Start Time" << "\n"
<< "3. To End" << "\n" << "\n";
cout << "Please input a value between 1 to 3: ";
cin >> menuOption;
cout << endl;
switch (menuOption) {
case 1:
{
int index = 0;
double High = 0.0;
for (int j = 0; j < salesVector.size(); j++) {
if (salesVector[j].price > High) {
index = j;
}
}
cout << "Highest Price and Start Time" << endl;
cout << "Date: " << salesVector[index].date << endl;
cout << "Highest Price: $" << salesVector[index].price << endl;
cout << "Starting Time: " << salesVector[index].time << "\n" << endl;
exit = false;
break;
}
case 2:
{
int index2 = 0;
double Low = 0.0;
for (int j = 0; j < salesVector.size(); j++) {
if (salesVector[j].price < Low) {
index2 = j;
}
}
cout << "Lowest Price and Start Time" << endl;
cout << "Date: " << salesVector[index2].date << endl;
cout << "Lowest Price: $" << salesVector[index2].price << endl;
cout << "Starting Time: " << salesVector[index2].time << "\n" << endl;
exit = false;
break;
}
case 3:
exit = true;
break;
default:
cout << "Error, Please Enter Again." << "\n" << endl;
exit = false;
break;
}
}
}
|
I am unable to upload any attachement, however, below is my file data
Petrol Statistics
Date/Time,Price ($),Volume,Value ($)
10/10/2013 4:57,5.81,5000,29050
10/10/2013 7:48,5.81,62728,364449.68
10/10/2013 16:10,5.82,100,582
10/10/2013 17:10,5.86,150,879
10/10/2013 17:11,5.23,169,883.87
10/10/2013 17:14,5.81,451,2620.31
10/10/2013 18:10,5.81,5000,29050
Below is my output results
Highest Price and Start Time
Date: 10/10/2013 10/10/2013
Highest Price: $5.82
STarting Time: 4.57:48 18:10:48
Lowest Price and Start Time
Date: 10/10/2013
Highest Price: $5.82
STarting Time: 4.57:48