Discount calculate program in c++

April 27, 2013

Discount calculate program in c++



OBJECT


Write a c++ program that take prince and department code from user and tells the discount and sales price of code using switch statement



Algorithm



STEP#1    Start
STEP#2    Declare the variables rp, sp, dc, discount
STEP#3    input price
STEP#4    input department code
STEP#5    switch dc
STEP#6    if case ‘310’
STEP#7    Discount=(10*rp)/100 and sp=rp-discount
STEP#8    Display sale price and discounted price
STEP#9    if case ‘438’
STEP#10    Discount=(12*rp)/100 and sp=rp-discount
STEP#11    Display sale price and discounted price
STEP#12    if case ‘284’
STEP#13    Discount=(8*rp)/100 and sp=rp-discount
STEP#14    Display sale price and discounted price
STEP#15    if case ‘652’
STEP#16    Discount=(15*rp)/100 and sp=rp-discount
STEP#17    Display sale price and discounted price
STEP#18    if default
STEP#19    Discount=(5*rp)/100 and sp=rp-discount
STEP#20    Display sale price and discounted price
STEP#21    End


CODING


#include <iostream>
using namespace std;
int main()
{
     int rp,sp,dc,discount;

     cout<<"Enter price = ";
     cin>>rp;
     cout<<"Enter department code = ";
     cin>>dc;
     switch(dc)
     {
          case'310':
          discount=(10*rp)/100;
          sp = rp-discount;
          cout<<"sale price =  "<<sp<<endl;
          cout<<"discounted price = "<<discount<<endl;
          break;
          case'438':
          discount=(12*rp)/100;
          sp= rp-discount;
          cout<<"sale price = "<<sp<<endl;
          cout<<"discounted price = "<<discount<<endl;
          break;
          case'284':
          discount=(8*rp)/100;
          sp= rp-discount;
          cout<<"sale price = "<<sp<<endl;
          cout<<"discounted price = "<<discount<<endl;
          break;
          case'652':
          discount=(15*rp)/100;
          sp= rp-discount;
          cout<<"sale price = "<<sp<<endl;
          cout<<"discounted price = "<<discount<<endl;
          break;
          default:
          discount=(5*rp)/100;
          sp= rp-discount;
          cout<<"sale price = "<<sp<<endl;
          cout<<"discounted price = "<<discount<<endl;
          break;
     }
     return 0;
}


Discount calculate program in c++

You Might Also Like

0 comments

Popular Posts

Like us on Facebook

Flickr Images