The C and C++ code snippets monologue forum

The C, C++, Code, Coder, Coding Snippets Zone for Tenouk.com

 

 
It is currently Thu Sep 09, 2010 12:43 am

All times are UTC




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: Determining the benefits
PostPosted: Mon Nov 13, 2006 9:45 am 
Offline

Joined: Sat Nov 11, 2006 1:15 pm
Posts: 280
Compiler: Visual C++ Express Edition 2005
Compiled on Platform: Windows XP Pro SP2
Header file: Standard
Additional project setting: Set project to be compiled as C++
Project -> your_project_name Properties -> Configuration Properties -> C/C++ -> Advanced -> Compiled As: Compiled as C++ Code (/TP)
Other info: none
To do: Determining the benefits for the given conditions
To show: if-else statement


Code:
// if-else statement example
#include <iostream>
using namespace std;

int main()
{
   int  job_code;
   double housing_allowance, entertainment_allowance, car_allowance;

   cout<<"Available job codes: 1 or non 1:\n"<<endl;
   cout<<"Enter job code: ";
   cin>>job_code;
      // if 1 is selected
   if(job_code==1)
   {
      car_allowance = 200.00;
      housing_allowance = 800.00;
      entertainment_allowance = 250.00;

      cout<<"--THE BENEFITS--\n";
      cout<<"Car allowance: "<<car_allowance<<endl;
      cout<<"Housing allowance: "<<housing_allowance<<endl;
      cout<<"Entertainment allowance: "<<entertainment_allowance<<endl;
   }
      // other than 1
   else
   {
      car_allowance = 100.00;
      housing_allowance = 400.00;
      entertainment_allowance = 150.00;

      cout<<"--THE BENEFITS--\n";
      cout<<"Car allowance: "<<car_allowance<<endl;
      cout<<"Housing allowance: "<<housing_allowance<<endl;
      cout<<"Entertainment allowance: "<<entertainment_allowance<<endl;
   }

   return 0;
}


Output:

Code:
Available job codes: 1 or non 1:

Enter job code: 1
--THE BENEFITS--
Car allowance: 200
Housing allowance: 800
Entertainment allowance: 250
Press any key to continue . . .


Code:
Available job codes: 1 or non 1:

Enter job code: 3
--THE BENEFITS--
Car allowance: 100
Housing allowance: 400
Entertainment allowance: 150
Press any key to continue . . .

_________________
None


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Skin by Lucas Kane