PROGRAM 9
// FILENAME: PROG9.CPP // THIS PROGRAM PRINTS A RECEIPT FOR HONEST ABE'S CARPETORIUM IF THE USER // REQUESTS IT. #include #include #include #include #include ofstream prnt; void main () { clrscr (); char my, qsheet; char carpet [10]; int length, width, type, yards; float price; #include gotoxy (6, 7); cout << " PROG9.CPP "; gotoxy (48, 14); my = getch (); window (1, 1, 80, 25); textbackground (3); clrscr (); clrscr (); gotoxy (23, 1); cout << "HONEST ABE'S CARPETORIUM"; gotoxy (22, 3); cout << "CARPET TYPES COST / YARD"; gotoxy (22, 5); cout << "1. QUALITY - $ 12.00"; gotoxy (22, 7); cout << "2. PREMIUM - $ 18.00"; gotoxy (22, 9); cout << "3. SUPERIOR - $ 22.00"; gotoxy (12, 11); cout << "CARPET TYPE DESIRED: "; gotoxy (12, 13); cout << " LENGTH DESIRED: "; gotoxy (51, 13); cout << "WIDTH DESIRED: "; gotoxy (12, 15); cout << " YARDS NEEDED: "; gotoxy (51, 15); cout << " PRICE: "; gotoxy (33, 11); cin >> type; gotoxy (33, 13); cin >> length; gotoxy (66, 13); cin >> width; yards = ((length * width) / 9) + 1; if (type == 1) { price = yards * 12.00; strcpy (carpet, "QUALITY"); } else {if (type == 2) { price = yards * 18.00; strcpy (carpet, "PREMIUM"); } else {if (type == 3) { price = yards * 22.00; strcpy (carpet, "SUPERIOR"); } else {if ((type < 1) || (type > 3)) { price = 0.0; return; } } } } gotoxy (33, 15); cout << yards; gotoxy (66, 15); cout.setf (ios :: showpoint); cout.setf (ios :: fixed); cout << setprecision (2) << price; gotoxy (3, 17); cout << "PRINT A QUOTE SHEET (Y OR N): "; cin >> qsheet; if ((qsheet != 'y') && (qsheet != 'Y')) { return; } clrscr (); prnt.open ("LPT1", ios :: out); prnt << " HONEST ABE'S CARPETORIUM \n\n"; prnt << " 1234 LINCOLN STREET\n"; prnt << " WASHINGTON, CA 56789\n\n\n\n\n"; prnt << " CUSTOMER'S RECEIPT\n"; prnt << " ------------------\n\n"; prnt << " CARPET TYPE: " << carpet << "\n\n"; prnt << " NUMBER OF YARDS: " << yards << "\n\n"; prnt << " TOTAL PRICE: " << price << "\n\f"; prnt.close (); return; } // FILENAME: COPY.H // SEE PROGRAM 7. // OUTFILE: PROG9.CPP HONEST ABE'S CARPETORIUM CARPET TYPES COST / YARD 1. QUALITY - $ 12.00 2. PREMIUM - $ 18.00 3. SUPERIOR - $ 22.00 CARPET TYPE DESIRED: 1 LENGTH DESIRED: 100 WIDTH DESIRED: 100 YARDS NEEDED: 1112 PRICE: 13344.00 PRINT A QUOTE SHEET (Y OR N): n
BACK TO CIS162 PAGE.