Professional Documents
Culture Documents
C
C
#include <conio.h>
#include <string>
#include <iomanip>
string band_album_names_sws[] = {"Madness", "Gossip", "Feel", "Let's Cheers to This", "With Ears to
See and Eyes to Hear"};
string band_album_names_mp[] = { "Black Lines", "Valdosta", "Monsters in the Closet", "A Lesson in
Romantics", "Anywhere But Here" };
double total_amount = 0;
void show_receipt() {
system("CLS");
cout << " *** " << "You have purchased: ***\n";
cout << " *** " << "Total amount: Php " << total_amount << endl;
cout << " *** " << "Amount payed: Php " << payment <<"00"<< endl;
cout << " *** " << "Change: Php " << payment - total_amount<< endl;
int show_band_names() {
cout << "(" << counter + 1 << ") " << band_names[counter] << endl;
while (cin.fail()) {
cin.clear();
cin.ignore();
do {
cout << endl << "Invalid input!" << endl << "Please select a band: ";
while (cin.fail()) {
cin.clear();
cin.ignore();
return band_index;
band_index--;
cout << "\nYou have selected " << band_names[band_index] << "." << endl << endl;
if (band_index == 0) {
if (cin.fail()) {
while (cin.fail()) {
cin.clear();
cin.ignore();
album_index--;
do {
cout << endl << "Invalid input!" << endl << "Please select an album: ";
album_index--;
if (cin.fail()) {
while (cin.fail()) {
cin.clear();
cin.ignore();
cout << endl << "Please select an album: ";
album_index--;
cout << endl << "You have selected " << band_album_names_sws[album_index];
cout << "\n\nHow many album would you like to avail? ";
if (cin.fail()) {
while (cin.fail()) {
cin.clear();
cin.ignore();
cout << "How many album would you like to avail? ";
while (cin.fail()) {
cin.clear();
cin.ignore();
do {
cout << endl << "Invalid input!" << endl << "Do you want to purchase
more?\n";
if (cin.fail()) {
while (cin.fail()) {
cin.clear();
cin.ignore();
cout << endl << "Do you want to purchase more?\n ";
if (confirm_reorder == 1) {
int reorder_band_index;
reorder_band_index = show_band_names();
show_band_albums(reorder_band_index);
else if (confirm_reorder == 2) {
cout << endl << "Total amount: Php " << total_amount << endl << endl << "Enter
amount of payment: Php ";
do {
cin.clear();
cin.ignore();
cout << "Invalid input!\n" << "Enter amount of payment: Php ";
cout << "\nChange: Php " << payment - total_amount << ".00";
}
}
/*mayday parade*/
else if (band_index == 1) {
cout << "(" << counter + 1 << ") " << band_album_names_mp[counter] << " -
Php " << band_album_names_mp_prices[counter] << endl;
if (cin.fail()) {
while (cin.fail()) {
cin.clear();
cin.ignore();
album_index--;
do {
cout << endl << "Invalid input.\n" << "Please select an album: ";
album_index--;
if (cin.fail()) {
while (cin.fail()) {
cin.clear();
cin.ignore();
album_index--;
cout << endl << "You have selected " << band_album_names_mp[album_index];
cout << "\n\nHow many album would you like to avail? ";
if (cin.fail()) {
while (cin.fail()) {
cin.clear();
cin.ignore();
cout << "How many album would you like to avail? ";
cout << endl << "Do you want to purchase more?\n" << "(1) Yes\n" << "(2) No" << endl;
while (cin.fail()) {
cin.clear();
cin.ignore();
do {
cout << endl << "Invalid input!" << endl << "Do you want to purchase
more?\n";
if (cin.fail()) {
while (cin.fail()) {
cin.clear();
cin.ignore();
cout << endl << "Do you want to purchase more?\n ";
if (confirm_reorder == 1) {
int reorder_band_index;
reorder_band_index = show_band_names();
show_band_albums(reorder_band_index);
else if (confirm_reorder == 2) {
cout << endl << "Total amount: Php " << total_amount << endl << endl << "Enter
amount of payment: Php ";
do {
cin.clear();
cin.ignore();
cout << "Invalid input!\n" << "Enter amount of payment: Php ";
int main () {
band_index = show_band_names();
show_band_albums(band_index);
show_receipt();
_getch();
return 0;