im writing this simple program and i am getting some errors. i dont know what th
ID: 3549737 • Letter: I
Question
im writing this simple program and i am getting some errors. i dont know what the problem is and hope someone can tell me
public static void main(String[] args) {
tax t= new tax();
t.grossincome=50000;
t.state="Virginia";
t.dependants=1;
double yourtax=t.calctax();
System.out.println("your tax is " + yourtax);
tax.java
public class tax {
double grossincome;
String state;
int dependants;
public double calctax() {
double stateTax=0;
if (grossincome > 30000){
stateTax=grossincome*0.06;
}
else {
stateTax= grossincome*0.05;
}
return stateTax;
}
}
Explanation / Answer
package tmp1; //ignore this
public class tax {
double grossincome;
String state;
int dependants;
public double calctax()
{
double stateTax=0;
if (grossincome > 30000)
{
stateTax=grossincome*0.06;
}
else
{
stateTax= grossincome*0.05;
}
return stateTax;
}
public static void main(String[] args) {
tax t= new tax();
t.grossincome=50000;
t.state="Virginia";
t.dependants=1;
double yourtax=t.calctax();
System.out.println("your tax is " + yourtax);
}
}
There is nothing wrong with it.
when i ran your code i got :
your tax is 3000.0
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.