Tuesday, February 7, 2017

use of if else in c++

#include<iostream>
#include<conio.h>
using namespace std;
main()
{
double amount, discount, netPayable ;  amount = 0 ;  netPayable = 0 ;   discount = 0 ;
   cout << "Please enter the amount of the bill"<<endl;
   cin >> amount;
if ( amount > 5000 )    
{              
     discount = amount * (15.0 / 100);              
  netPayable = amount - discount;
  cout << "The payable amount is=Rs" << netPayable <<endl;        
   cout << "The discount at the rate 15 % is=Rs" << discount << endl;      
   }  
       else            
{
       discount = amount * (10.0 / 100);          
                  cout << "The discount at the rate 10 % is=Rs" << discount<< endl;
netPayable = amount - discount ;    
cout << "The payable amount is=Rs" << netPayable;
}
}
   

0 comments:

Post a Comment