English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

Algorithm:
1. Read Basic Salary as bsalary
2. Calculate DA = 0.05 * bsalary
3. Calculate HRA = 0.10 * bsalary
4. Calculate TAX = 0.15 * bsalary
5. Calculate Insurance = 0.25 * bsalary
6. Calculate NetPay=bsalary+DA+HRA-TAX-Insu...
7. Display NetPay

I want to code this in some language. need help.

2007-02-15 07:17:04 · 3 answers · asked by art_007 1 in Computers & Internet Programming & Design

3 answers

Here is your solution in C++. As you know I answer most of the answers of C/C++(Statements after // are comments in the program)

Here it is:


#include
#include

void main()
{
// Declaring variables
float bsalary;
float DA,HRA,TAX,Insurance,NetPay;

// 1. Read Basic Salary as bsalary
cout<<"\n Enter Basic Salary ";
cin>>bsalary;

//2. Calculate DA = 0.05 * bsalary
DA = 0.05 * bsalary

//3. Calculate HRA = 0.10 * bsalary
HRA = 0.10 * bsalary

//4. Calculate TAX = 0.15 * bsalary
TAX = 0.15 * bsalary

//5. Calculate Insurance = 0.25 * bsalary
Insurance = 0.25 * bsalary

//6. Calculate NetPay=bsalary+DA+HRA-TAX-Insurance
NetPay=bsalary+DA+HRA-TAX-Insurance

//7. Display NetPay
cout<<"\n The Net Pay is "<
getch();
}

If require further clarifications, u may query me again.


OM NAMAH SHIVAY

2007-02-15 16:07:35 · answer #1 · answered by Gurudev 3 · 0 0

But you've already done it , albeit bar a couple of lines!

What you've given will directly translate into any language
you'd care to mention. So *where* is the problem?

// program starts ..
//
var bsalary
var DA = 0.05 * bsalary
var HRA = 0.10 * bsalary
var TAX = 0.15 * bsalary
var Insurance = 0.25 * bsalary
var NetPay=bsalary+DA+HRA-TAX-Insu...
print NetPay
//
//program ends.


HTH

PS Hey, Math Guy .. how many languages should we actually do this in? How about one line, and in Perl? ;o)

2007-02-15 07:30:17 · answer #2 · answered by Chipz 3 · 0 0

// Java
public void doSalary(double bsalary)
{
double DA;
double HRA;
double TAX;
double Ins;
double net;
bsalary = Double.parseDouble(
new BufferedReader(
new InputStreamReader( System.in ) )).readLine())
DA = bsalary * 0.05;
HRA = bsalary * 0.1;
TAX = bsalary * 0.15;
Ins = bsalary * 0.25
net = DA + HRA + TAX + Ins + net + bsalary;
System.out.println(bsalary);
}

2007-02-15 07:37:46 · answer #3 · answered by Math Guy 4 · 0 0

fedest.com, questions and answers