- Joined
- May 22, 2015
- Posts
- 1,194
- Solutions
- 101
- Reaction
- 1,211
- Points
- 601
Attachments
-
You do not have permission to view the full content of this post. Log in or register now.
opo sircode ba nyan ang need mo?
import java.util.*;
public class test2 {
static Scanner console = new Scanner(System.in);
static void GetData() {
//Process #1 (Receive the data entered by the user)
System.out.println("Monthly Income: ");
int MonthlyIncome = console.nextInt();
System.out.println("Did you have a Spouse that is Working?(Y/N): ");
String temp = console.next();
char HaveSpouse = temp.charAt(0);
System.out.println("Input how many children you have: ");
int NumberofChildren = console.nextInt();
Processor(MonthlyIncome, HaveSpouse, NumberofChildren);
}
//Output the processed data
static void PutData(int AnnualIncome, int BasicExemption, int ExemptionForSpouse, int ExemptionForChildren,int IncomeToAssetTax,int IncomeTaxPerYear, int IncomeTaxPerMonth) {
System.out.println("Annual Income: "+AnnualIncome);
System.out.println("Basic Exemption: "+BasicExemption);
System.out.println("Exemption for Spouse: "+ExemptionForSpouse);
System.out.println("Exemption for Children: "+ExemptionForChildren);
System.out.println("Income to Asset Tax:"+IncomeToAssetTax);
System.out.println("Income Tax per Year: "+IncomeTaxPerYear);
System.out.println("Income Tax per Month: "+IncomeTaxPerMonth);
}
static void Processor(int MonthlyIncome, char HaveSpouse, int NumberofChildren) {
//Process #2 (Calculates the annual income)
int AnnualIncome = MonthlyIncome * 12; //Process 2d
int BasicExemption = (int)(AnnualIncome * 0.2); //Process 2e
int ExemptionForSpouse = 0; //Process 2f
if(HaveSpouse == 'Y' || HaveSpouse == 'y')
ExemptionForSpouse = 300; // The user have a wife
int ExemptionForChildren = 200 * NumberofChildren; //Process 2g
int IncomeToAssetTax = AnnualIncome - BasicExemption - ExemptionForSpouse - ExemptionForChildren; //Process 2h
//Process #3 (Calculates the Income Tax)
//Initialze the things needed for the table
int[] Amount = {500,500,500,500,1000,1000,2000,2000,2000,5000,5000};
int[] TaxRate = {1,2,3,4,5,6,7,8,10,12,15,20};
int[] AllocatedIncome = new int[12];
int[] TaxToPay = new int[12];
AllocatedIncome[0] = IncomeToAssetTax;
int IncomeTaxPerYear = 0;
if(IncomeToAssetTax > 500) {
for(int i = 0; i < 11 && AllocatedIncome[i] > 0; i++) {
if(AllocatedIncome[i] > Amount[i]) {
AllocatedIncome[i+1] = AllocatedIncome[i] - Amount[i];
AllocatedIncome[i] = Amount[i];
}
if(i < 12 && AllocatedIncome[i] > 0) {
TaxToPay[i] = (int) AllocatedIncome[i] * TaxRate[i] / 100;
IncomeTaxPerYear = IncomeTaxPerYear + TaxToPay[i];
}
}
}
int IncomeTaxPerMonth = IncomeTaxPerYear / 12;
PutData(AnnualIncome, BasicExemption, ExemptionForSpouse, ExemptionForChildren, IncomeToAssetTax, IncomeTaxPerYear, IncomeTaxPerMonth);
}
////Driver to start the program
public static void main(String[] args) {
GetData();
}
}
maraming salamat po sir! pagaralan ko po yaneto paps, pagaralan mong mabuti,
Java:import java.util.*; public class test2 { static Scanner console = new Scanner(System.in); static void GetData() { //Process #1 (Receive the data entered by the user) System.out.println("Monthly Income: "); int MonthlyIncome = console.nextInt(); System.out.println("Did you have a Spouse that is Working?(Y/N): "); String temp = console.next(); char HaveSpouse = temp.charAt(0); System.out.println("Input how many children you have: "); int NumberofChildren = console.nextInt(); Processor(MonthlyIncome, HaveSpouse, NumberofChildren); } //Output the processed data static void PutData(int AnnualIncome, int BasicExemption, int ExemptionForSpouse, int ExemptionForChildren,int IncomeToAssetTax,int IncomeTaxPerYear, int IncomeTaxPerMonth) { System.out.println("Annual Income: "+AnnualIncome); System.out.println("Basic Exemption: "+BasicExemption); System.out.println("Exemption for Spouse: "+ExemptionForSpouse); System.out.println("Exemption for Children: "+ExemptionForChildren); System.out.println("Income to Asset Tax:"+IncomeToAssetTax); System.out.println("Income Tax per Year: "+IncomeTaxPerYear); System.out.println("Income Tax per Month: "+IncomeTaxPerMonth); } static void Processor(int MonthlyIncome, char HaveSpouse, int NumberofChildren) { //Process #2 (Calculates the annual income) int AnnualIncome = MonthlyIncome * 12; //Process 2d int BasicExemption = (int)(AnnualIncome * 0.2); //Process 2e int ExemptionForSpouse = 0; //Process 2f if(HaveSpouse == 'Y' || HaveSpouse == 'y') ExemptionForSpouse = 300; // The user have a wife int ExemptionForChildren = 200 * NumberofChildren; //Process 2g int IncomeToAssetTax = AnnualIncome - BasicExemption - ExemptionForSpouse - ExemptionForChildren; //Process 2h //Process #3 (Calculates the Income Tax) //Initialze the things needed for the table int[] Amount = {500,500,500,500,1000,1000,2000,2000,2000,5000,5000}; int[] TaxRate = {1,2,3,4,5,6,7,8,10,12,15,20}; int[] AllocatedIncome = new int[12]; int[] TaxToPay = new int[12]; AllocatedIncome[0] = IncomeToAssetTax; int IncomeTaxPerYear = 0; if(IncomeToAssetTax > 500) { for(int i = 0; i < 11 && AllocatedIncome[i] > 0; i++) { if(AllocatedIncome[i] > Amount[i]) { AllocatedIncome[i+1] = AllocatedIncome[i] - Amount[i]; AllocatedIncome[i] = Amount[i]; } if(i < 12 && AllocatedIncome[i] > 0) { TaxToPay[i] = (int) AllocatedIncome[i] * TaxRate[i] / 100; IncomeTaxPerYear = IncomeTaxPerYear + TaxToPay[i]; } } } int IncomeTaxPerMonth = IncomeTaxPerYear / 12; PutData(AnnualIncome, BasicExemption, ExemptionForSpouse, ExemptionForChildren, IncomeToAssetTax, IncomeTaxPerYear, IncomeTaxPerMonth); } ////Driver to start the program public static void main(String[] args) { GetData(); } }