#include #include #include const int MAXSTRLEN = 50; // maximum character length of a string const float MPRICE = 269.95; // price of a mountain bike const float SPRICE = 149.50; // price of a street bike struct Customer { char name[MAXSTRLEN]; char address[MAXSTRLEN]; int numbikes; char biketype; char goodrisk; float amount; }; Customer recvorder(); // function prototype needed for main() void shipslip(Customer); // function prototype needed for main() int main() { Customer client; client = recvorder(); // enter the order shipslip(client); // prepare shipping instructions return 0; } // enter an order // precondition: requires MPRICE, which is the price of a mountain bike // : and SPRICE, which is the price of a street bike Customer recvorder() // return a structure of type Customer { Customer record; // record is local to this function char btype = 'N'; char risk = 'U'; float price; cout << "\nEnter customer information: "; cout << "\n Name: "; cin.getline(record.name, MAXSTRLEN); cout << " Address: "; cin.getline(record.address, MAXSTRLEN); cout << "\nHow many Bicycles are ordered: "; cin >> record.numbikes; cout << "Type of Bicycle ordered:"; while( !(btype == 'M' || btype == 'S') ) { cout << "\n M Mountain"; cout << "\n S Street"; cout << "\nChoose one (M or S): "; cin >> btype; btype = toupper(btype); // make sure its in uppercase } // determine the price of the bike if (btype == 'M') price = MPRICE; else if (btype == 'S') price = SPRICE; record.amount = record.numbikes * price; record.biketype = btype; while( !(risk == 'Y' || risk == 'N') ) { cout << "\nIs this customer a good risk (Y or N): "; cin >> risk; risk = toupper(risk); } record.goodrisk = risk; return record; } // prepare a shipping list void shipslip(Customer record) { cout << "\n Shipping Instructions:"; cout << "\nTo: " << record.name; cout << "\n " << record.address; cout << "\nShip: " << record.numbikes; if (record.biketype == 'M') cout << " Mountain Bikes"; else if (record.biketype == 'S') cout << " Street Bikes"; // set output formats cout << setw(6) << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(2); if (record.goodrisk == 'Y') cout << "\nby freight, and bill the customer $" << record.amount << endl; else cout << "\nC.O.D. Amount due on delivery = $" << record.amount << endl; return; }