Using c++ Language ALGORITHNIC LOGIC FORMULATION 8Asiaclean Corp. gives commissi
ID: 3868502 • Letter: U
Question
Using c++ Language
Explanation / Answer
#include <iostream>
#include <string>
#include <cstdlib>
using namespace std;
class sales
{
public: //variable declaration
string pc,pn;
double sa,comm,t;
void calc()
{
cout<<"Enter the product code : "; //accepting the prodcut code from user
cin>>pc;
cout<<endl;
cout<<"Enter the Sales Amount : "; //accepting the total sales amount from user
cin>>sa;
cout<<endl;
if(pc=="VC") //calculating the commission according teo the prodcut code
comm=0.12*sa;
else if(pc=="WP")
comm=250;
else if(pc=="FP")
{
t=0.1*sa;
if(t<400)
comm=t;
else
comm=400;
}
else if(pc=="WT")
{
t=0.15*sa;
if(t>950)
comm=t;
else
comm=950;
}
else
{
cout<<"Invalid Product Code";
exit(0);
}
}
void display()
{
if(pc=="VC")
pn="Vaccum Cleaner";
else if(pc=="WP")
pn="Water Purifier";
else if(pc=="FP")
pn="Floor Polisher";
else
pn="Water Tank"; //printing the details
cout<<"Product Name : "<<pn<<endl;
cout<<"Product Code : "<<pc<<endl;
cout<<"Commission :Rs "<<comm<<endl;
}
};
int main()
{
sales obj; //object of the class
obj.calc(); //calling the calc function
obj.display(); //calling the display funciton
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.