Tax Calculator App
Tax Calculator App
Problem Statement: Vaibhav has just completed his first year of Job. He is really happy about it but at the same time he needs to pay taxes to government on what he has earned in his last one year. Vaibhav found that all of his friends were facing the same difficulty in calculating the tax.
He felt the need of a program where he can enter all of his friend’s name along with their income one by one and the program will calculate the tax and print the liable taxes of all of his friends.
JAVA code
package com.company; import java.util.Scanner; public class Main { public static void main(String[] args) { System.out.println(" Tax Calculator App "); System.out.println(" ------WELCOME------"); long MyCT = 0; int j=0; System.out.println("Enter total person count"); Scanner Persons = new Scanner(System.in); int NoOfPersons = Integer.parseInt(Persons.nextLine()); String[] Names = new String[NoOfPersons] ; long[] CT = new long[NoOfPersons]; for (int i=0 ; i<NoOfPersons ; i++) { j++; System.out.println("Enter name "+j); String MyNames = Persons.nextLine(); Names[i] = MyNames; System.out.println("Enter "+Names[i]+"'s Annual Income: "); MyCT = Integer.parseInt(Persons.nextLine()); CT[i] = MyCT; ; } System.out.println(" Names with liable taxes"); System.out.println(" ----------------------------"); Tax(CT, Names, NoOfPersons); } public static void Tax( long[] CT , String[] Names, int NoOfPersons){ for (int i=0; i<NoOfPersons; i++){ if (CT[i]<100000){ System.out.println(Names[i]+": $ 0"); } else if (CT[i]>=100000&&CT[i]<300000){ double Taxes =0.1*CT[i]; System.out.println(Names[i]+": $ "+Taxes); } else if (CT[i]>=300000){ double Taxes =0.2*CT[i]; System.out.println(Names[i]+": $ "+Taxes); } } } }
package com.company; import java.util.Scanner; public class NumberOfPersons { public String name; public long Income; public double tax; ; }
Comments
Post a Comment