61 lines
1.4 KiB
C++

#include <iostream>
#include <ctime>
using namespace std;
void menu() {
cout << "============================" << endl;
cout << "=========== MENU ===========" << endl;
cout << "============================" << endl;
cout << "1 ... GENERATE WATER INTAKES" << endl;
cout << "2 ... PRINT WATER INTAKES" << endl;
cout << "0 ... EXIT" << endl;
cout << "============================" << endl;
cout << "Select: ";
}
void fillArray(float* array, const unsigned int size) {
for (unsigned int i = 0; i < size; i++) {
array[i] = 0.5f + i * 0.3f;
}
}
void printArray(const float* array, const unsigned int size) {
for (unsigned int i = 0; i < size; i++) {
cout << ((i > 0) ? ", " : "") << array[i];
}
}
int main() {
const unsigned int days = 10;
float* waterIntakes = new float[days];
srand(time(nullptr));
bool running = true;
int selection;
do {
menu();
cin >> selection;
switch (selection) {
case 1:
fillArray(waterIntakes, days);
break;
case 2:
printArray(waterIntakes, days);
break;
case 0:
running = false;
break;
default:
cout << "Wrong selection!" << endl;
break;
}
cout << endl;
} while (running);
delete[] waterIntakes;
return 0;
}