howdy guys, I've been messing with this program for the last couple of days for my intro to c++ class. I know I'm doing stuff wrong in here but not sure what it is. Anyone have suggestions on maybe how I can do the calculations more efficiently and maybe even the whole program?
Code:#include <iostream> #include <iomanip> using namespace std; const double RED_RUG = 4.99; const double GREEN_RUG = 5.99; const double BLUE_RUG = 6.99; int main(void) { char* discount; char customerName[25]; char rugColor; char paymentMethod; int roomLength; int roomWidth; char* rugDisplay; char* discountPercent; int roomArea; double endDiscount; double paidDiscount; double rugCost; double carpetCost; cout<<setw(20)<<"Welcome to..."<<endl; cout<<endl; cout<<setw(40)<<">>>Toupay's Warehouse<<<<"<<endl; cout<<endl; cout<<setw(35)<<"The Best in rugs"<<endl; cout<<endl; cout<<"If you enter the customers name, type of rug purchased,"<<endl; cout<<"room dimensions, and type of payment, this program"<<endl; cout<<"will calculate and print a bill to the screen"<<endl; cout<<"Please enter the customers name: "; cin.getline(customerName,25); cout<<endl; cout<<"Please enter rug color (R)ed (B)lue (G)reen: "; cin>>rugColor; cout<<endl; if (rugColor == 'R') { rugDisplay = "RED"; } else if (rugColor == 'B') { rugDisplay = "BLUE"; } else if(rugColor == 'G') { rugDisplay = "GREEN"; } else rugDisplay = "N/A"; cout<<endl; cout<<"Please enter the method of payment"<<endl; cout<<"(C)ash (Z)ippy or (O)ther: "; cin>>paymentMethod; if (paymentMethod == 'C') { discount = "Cash and Carry"; } else if (paymentMethod == 'Z') { discount = "Zippy Discount"; } else if (paymentMethod == 'O') { discount = "No Discount"; } else discount = "N/A"; if (paymentMethod == 'C') { discountPercent = "Cash and Carry 10%"; } else if (paymentMethod == 'Z') { discountPercent = "Zippy Discount 5%"; } else if (paymentMethod == 'O') { discountPercent = "No Discount"; } else { discountPercent = "N/A - No discount type specified"; } cout<<endl; cout<<"Enter the Length of your room: "; cin>>roomLength; cout<<endl; cout<<"Enter the Width of your room: "; cin>>roomWidth; roomArea = (roomWidth * roomLength); cout<<endl; cout<<setw(40)<<">>>Toupay's Warehouse<<<<"<<endl; cout<<endl; cout<<setw(35)<<"The Best in rugs"<<endl; cout<<endl; cout<<"Customer Name:"<<setw(26)<<customerName<<endl; cout<<endl; cout<<"Rug Color:"<<setw(30)<<rugDisplay<<endl; cout<<endl; cout<<"Payment Method:"<<setw(25)<<discount<<endl; cout<<endl; cout<<"Discount:"<<setw(18)<<discountPercent<<endl; cout<<endl; if (paymentMethod == 'C') paidDiscount = .10; else if (paymentMethod == 'Z') paidDiscount = .05; else paidDiscount = 1; if (rugDisplay == "RED") rugCost = RED_RUG; else if (rugDisplay == "BLUE") rugCost = BLUE_RUG; else if (rugDisplay == "GREEN") rugCost = GREEN_RUG; else rugCost =6.99; endDiscount = (roomArea * rugCost * paidDiscount); if (paidDiscount == '0') endDiscount = "0" cout<<"Discount: "<<setw(25)<<"$"<<endDiscount<<endl; carpetCost = (roomArea * rugCost); cout<<"Final Cost:"<<setw(23)<<"$"<<carpetCost<<endl; return 0;