You are on page 1of 4

import java.util.

*; public class Tax { double double double double double double double stat; netIncome; gross; ans; totalTaxDue; taxIn; ann;

{ double dep=0; System.out.println("Input the number of dependents:"); dep=Input.readDouble(); taxIn=(ann-3200.0)+ (dep*800.0); netIncome=(ann-3200.0)+ (dep*800.0)/12; System.out.print("Your net income is:\n"+netIncome); } if(taxIn<=1000.0) { ans=taxIn*0.5; System.out.println("\nThe tax due is:"+totalTaxDue); } if((taxIn>10000.0)&&(taxIn<=30 000.0)) { ans=(taxIn-10000)*0.10; totalTaxDue=500.0+ans; System.out.println("\nThe tax due is:"+totalTaxDue); } if((taxIn>30000.0)&&(taxIn<=70 000.0)) { ans=(taxIn-30000)* 0.15; totalTaxDue=2500.0+ans; System.out.println("\nThe tax due is:"+totalTaxDue); } if((taxIn>70000.0)&&(taxIn<=14 00000.0)) { ans=(taxIn-70000)*0.20; totalTaxDue=8500.0+ans; System.out.println("\nThe tax due is:"+totalTaxDue); } if((taxIn>140000.0)&&(taxIn<=2 50000.0)) { ans=(taxIn-140000)*0.25; totalTaxDue=22500.0+ans; System.out.println("\nThe tax due is:"+totalTaxDue); } if((taxIn>250000.0)&&(taxIn<=5 00000.0)) {

public double taxDue() { do { System.out.println("\nPlease input your income:"); gross=Input.readDouble(); ann=gross*12.0; System.out.println("Your annual income is:"+ann); System.out.println("\nStatus:\n 1=single\n 2=head of the family\n 3=married without dependents\n 4=married with dependents\n"); System.out.print("Pleasa input your Status:\n"); stat=Input.readDouble(); if(stat==1) { taxIn= (ann-20000.0); netIncome= (ann-20000.0)/12; System.out.print("Your net income is:\n"+netIncome); } if(stat==2) { taxIn= (ann-25000.0); netIncome= (ann-20000.0)/12; System.out.print("Your net income is:\n"+netIncome); } if(stat==3) { taxIn= (ann-32000.0); netIncome= (ann-20000.0)/12; System.out.print("Your net income is:\n"+netIncome); } if(stat==4)

ans=(taxIn-250000)*0.30; totalTaxDue=50000.0+ans; System.out.println("\nThe tax due is:"+totalTaxDue); } if(taxIn>=500000) { ans=(taxIn-50000)*0.34; totalTaxDue=125000.0+ans; System.out.println("\nThe tax due is:"+totalTaxDue); } import static java.lang.Math.*; public class Execution { public static void main(String[] args) { System.out.print("------------------pow--------------------\n"); System.out.print("Input your base:"); int x=Input.readInt(); System.out.print("Input your exponent:"); int y=Input.readInt(); int totalPow= (int)Math.pow(x,y); System.out.printf("the equivalent is %d\n",totalPow); System.out.print("------------------max--------------------\n"); System.out.print("Input your x:"); int a=Input.readInt(); System.out.print("Input your y:"); int b=Input.readInt(); if(a>b) System.out.printf("the max is %d\n",a); else System.out.printf("the max is %d\n",b); System.out.print("------------------len--------------------\n"); System.out.print("Input your string:"); String s=Input.readString(); int numberOfChar=s.length(); System.out.printf("the number of characters:%d\n",numberOfChar);

}while(gross!=0.0); return stat; } public static void main(String[] args) { Tax t=new Tax(); t.taxDue(); } }

System.out.print("-------------concatenateAll---------------\n"); System.out.print("Input your string1:"); String one=Input.readString(); System.out.print("Input your string2:"); String two=Input.readString(); System.out.print("Input your string3:"); String three=Input.readString(); String all= one+ two+ three; System.out.println("Concatenation: "+all); System.out.print("-----------------average------------------\n"); double ave=0.0; for(int i=0;i<5; i++) { System.out.print("number:"); ave=Input.readDouble()+ave; } double totalAve=ave/5; System.out.println("The average is:\n"+totalAve); System.out.print("---------------oddEven--------------------\n"); System.out.print("Input your x:"); int h=Input.readInt(); int ans=(h%2); if(ans==0) System.out.printf("%d is even\n", h); else System.out.printf("%d is odd\n", h); System.out.print("-----------------factorial----------------\n"); System.out.print("Input your x:");

int f=Input.readInt(); int k=1; int g=0; for(int i=1; i<=f; i++) { k=i*k; g=k; } System.out.printf("the factorial is: %d\n", g); System.out.print("------------------min--------------------\n"); System.out.print("Input your x:"); int aa=Input.readInt(); System.out.print("Input your y:"); int bb=Input.readInt(); if(aa<bb) System.out.printf("the min is %d\n",aa); else System.out.printf("the min is %d\n",bb); System.out.print("-----------------isPrime------------------\n"); System.out.println("Input your number:"); int number=Input.readInt(); int sol= (number*number)+1; if(sol%2==0) { System.out.printf("%d is a prime number\n",number);

} else { System.out.printf("%d is not a prime number\n", number); } System.out.print("------------------gcd---------------------\n"); System.out.println("Input your number1:"); int number1=Input.readInt(); System.out.println("Input your number2:"); int number2=Input.readInt(); int ma; do { if(number1>number2) { number1=number1-number2; ma=number1; } else { number2=number2-number1; ma=number2; } }while(number1!=number2); System.out.println("the GCD is:"+ma); } }

import static java.lang.Math.*; public class Utility { public static int power(int x, int y) { int totalPow=0; totalPow= (int)Math.pow(x,y); }

return totalPow;

public static int max(int x, int y) { if(x>y) return x; else return y;

} public static int len(String s) { int numberOfChar=0; numberOfChar=s.length(); return numberOfChar; } public static void oddEven(int h) { h=0; int ans=(h%2); } public static int fact(int f) { int g=0; for(int i=1; i<=f; i++) { int v=i*f; g=v; } } return g; } }

if(x>y) return x; else return y;

public static int gcd(int x, int y) { x=0; y=0; int ma=0; do { if(x>y) { x=x-y; ma=x; } else { y=y-x; ma=y; } }while(x!=y); return ma;

public static String concatenateAll() { String one=""; String two=""; String three=""; String all=one+ two+ three; return all; } public static double average() { double ave=0.0; for(int i=0;i<5; i++) { System.out.print("number:"); ave=Input.readDouble()+ave; } return ave; } public static int min() { int x=0; int y=0;

You might also like