ผมทำโค้ดนี้ขึ้นมาแล้ว คอมไพล์ได้ รันได้ แต่เวลาให้กรอกมันบอกให้กรอก2 ครั้ง ในเมื่อผมเขียนแค่ครั้งเดียว
import java.util.Scanner;
public class TAX {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("Please Input your salary : ");
int salary = sc.nextInt();
float tax = sc.nextFloat();
System.out.println("YOUR HAVE SALARY: "+salary);
if(salary <=100000){
tax=(salary*5)/100;
System.out.print("Your tax is :"+tax+"bath");
}
else if (salary>=100001 & salary<=500000){
tax=((salary)*10/100);
System.out.print("Your tax is :"+tax+"bath");
}
else if (salary>=500001 & salary<=1000000){
tax=((salary)*20/100);
System.out.print("Your tax is :"+tax+"bath");
}
else if (salary>=1000001 & salary<=4000000){
tax=(salary)*30/100;
System.out.print("Your tax is :"+tax+"bath");
}
else if (salary>4000001){
tax=(salary)*30/100;
System.out.print("Your tax is :"+tax+"bath");
}
}
}
งง !!โปรแกรม คำนวณภาษีเงินได้ Java
import java.util.Scanner;
public class TAX {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("Please Input your salary : ");
int salary = sc.nextInt();
float tax = sc.nextFloat();
System.out.println("YOUR HAVE SALARY: "+salary);
if(salary <=100000){
tax=(salary*5)/100;
System.out.print("Your tax is :"+tax+"bath");
}
else if (salary>=100001 & salary<=500000){
tax=((salary)*10/100);
System.out.print("Your tax is :"+tax+"bath");
}
else if (salary>=500001 & salary<=1000000){
tax=((salary)*20/100);
System.out.print("Your tax is :"+tax+"bath");
}
else if (salary>=1000001 & salary<=4000000){
tax=(salary)*30/100;
System.out.print("Your tax is :"+tax+"bath");
}
else if (salary>4000001){
tax=(salary)*30/100;
System.out.print("Your tax is :"+tax+"bath");
}
}
}