Computer Science, asked by ranjanprasad03856, 1 year ago

a Java program to calculate the ,income tax for a taxable income of rs 4,20,000 if the tax rate is fixed at 3.2%

Answers

Answered by Raghav1330
2

Answer:

The class and main program is depicted as below

Explanation:

import java.util.*;

class Taxes

{

private:

double salary= 4,20,000 ;

float tax=3.2 ;

public:

void calcTax();

{

float tax_amt = salary* tax/100;

}

}

class Taxmain

{

public static void main (string args[])

{

Tax t= new Tax

t.calcTax();

System.out.print(tax_amt);

}

}

Hence in this code we first apply a class named tax where they data are private and method function are made public.

In main function we have created an object. This object is used to invoke public function calcTax and the tax amount is calculated by that float variable tax_amt

Answered by lovingheart
5

A Java program to calculate the income tax:

public static void main (string args[])

{

double salary= 4,20,000 ;

float tax=3.2 ;

float tax_amt = salary* tax/100;

System.out.print(tax_amt);

}

Here the salary and tax are hardcoded because it has been given the question. You can also change this by obtaining dynamic values from the user. The tax is calculated using the formula “salary * tax/100”.

Necessary header files needs to be included. The same program can be modified to bring OOPS concept by bringing “class and object concept”.

Similar questions