Hi Im a beginner(obviously)currently writting a program for my assigment on Dev++ (version 5.11), the assignment question stated that "Your C++ Program Must Declare tax rate as Constant"
I've try to declared it as
const tax=(3/100);
but it still prompted an error that says "tax does not name a type"
have tried to find solutions multiple forum post, but couldn't find anything.
i've tried to changed it to
const double tax=(3/100);
but this one does nothing because the end product still doesn't count the total amount of tax
//Program to generate a customer's bill for company
#include<iostream>
usingnamespace std;
int main()
{
double cds,keyboards,printers,pendrives,speakers;
cout<<"====================== Bill Generator ======================== \n"<<endl;
cout<<" Enter The Amounts of CDs (per pack): "; //enter the amount of the items
cin>>cds; //program will receive inputs from tthe user
cout<<" Enter The Amounts of Keyboards: ";
cin>>keyboards;
cout<<" Enter The Amounts of Printers: ";
cin>>printers;
cout<<" Enter The Amounts of Pendrives: ";
cin>>pendrives;
cout<<" Enter The Amounts of Speakers: ";
cin>>speakers;
double unit_price_cd=60.00;//unit price is price for one item
double unit_price_keyboard=130.00;
double unit_price_printer=550.00;
double unit_price_pendrive=50.00;
double unit_price_speaker=150.00;
const tax=(3/100);//tax equals 3% of the sub total
double total_price_cd=cds*unit_price_cd;//total price for item based on the quantity given
double total_price_keyboard=keyboards*unit_price_keyboard;
double total_price_printer=printers*unit_price_printer;
double total_price_pendrive=pendrives*unit_price_pendrive;
double total_price_speaker=speakers*unit_price_speaker;
double sub_total=total_price_cd+total_price_keyboard+total_price_printer+total_price_pendrive+total_price_speaker;//sub total is price for all items
double tax_amount=tax*sub_total;//total amount of tax
double total=sub_total+tax_amount;//total for all item plus tax
cout<<" "<<endl;
cout<<"============================================================== \n"<<endl;
cout<<"QTY DETAILS UNIT PRICE TOTAL PRICE"<<endl;
cout<<"____ _______ __________ ___________"<<endl;
cout<<" "<<endl;
cout<<cds<<" CD 60.00 "<<"\t "<<total_price_cd<<".00"<<endl;
cout<<keyboards<<" KEYBOARD 130.00 "<<"\t"<<total_price_keyboard<<".00"<<endl;
cout<<printers<<" PRINTER 550.00 "<<"\t"<<total_price_printer<<".00"<<endl;
cout<<pendrives<<" PENDRIVE 50.00 "<<"\t"<<total_price_pendrive<<".00"<<endl;
cout<<speakers<<" SPEAKER 150.00 "<<"\t"<<total_price_speaker<<".00"<<endl;
cout<<" ___________"<<endl;
cout<<" SUB TOTAL "<<sub_total<<".00"<<endl;
cout<<" TAX "<<tax_amount<<".00"<<endl;
cout<<" TOTAL "<<total<<".00"<<endl;
return 0;
}