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 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114
|
#include <iostream>
#include <string>
#include <iomanip>
#include <cctype>
using namespace std;
//Structure-------------------------------
struct Day_t
{
string day;
};
//Function Prototypes---------------------
void displayMenu();
void displayExpenses(int *, Day_t[]);
void sortExpenses(int *, Day_t[]);
void searchExpenses(int *, Day_t[]);
int main() {
int expenses[2][7];
Day_t week[7];
week[0].day = "Monday", week[1].day = "Tuesday", week[2].day = "Wednesday", week[3].day = "Thursday", week[4].day = "Friday", week[5].day = "Saturday", week[6].day = "Sunday";
//Input Data for 2D Array [2][7]-------
for (int i = 0; i < 2; i++)
{
for (int j = 0; j < 7; j++)
{
cout << "Enter expenses for week " << i + 1 << ", day " << j + 1 << ": ";
cin >> expenses[i][j];
}
cout << endl;
}
//Display Main Menu for Select Options----------------
displayMenu();
char selection = 'z';
bool quit = false;
while (!quit)
{
cout << "Please enter your selection: \n";
cin >> selection;
switch (selection)
{
case '1': displayExpenses(*expenses, week);
break;
//case '2': sortExpenses(*expenses, week);
break;
//case '3': searchExpenses(*expenses, week);
break;
case '5': quit = true;
break;
default: cout << "You did not enter a valid input. Please enter a number 1-5..." << endl;
}
}
return 0;
}
void displayMenu()
{
cout << "\t Two-Week Expense Report\n"
<< "Enter 1 to display the data\n" //1 function
<< "Enter 2 to sort expenses in ascending order\n" //2 function
<< "Enter 3 to search for largest expense\n" //3 function
<< "Enter 5 to exit\n\n";
}
void displayExpenses(int *arr, Day_t week[])
{
for (int x = 0; x < 7; x++)
{
cout << week[x].day << " ";
}
cout << endl;
for (int i = 0; i < 2; i++)
{
for (int j = 0; j < 7; j++)
{
cout << (*(arr + i)+j);
}
cout << endl;
}
}
void sortExpenses(int *arr, Day_t week[])
{
}
void searchExpenses(int *arr, Day_t week[])
{
}
| |