What's new
  • Welcome to PHCorner Forums. Take a moment to Sign up and gain unlimited access and extra privileges that guests are not entitled to, such as: All that and more! Registration is quick, simple and absolutely free. Join our community today!

Help pseudocode to java

Heathcliff

Honorary Poster
Established
Joined
May 22, 2015
Messages
754
Reaction
109
Hello po pwede po patulong maconvert ung pseudocode into java di po kasi kami tinuturuan nung prof namin sa javaCapture+_2019-12-08-13-06-57.pngCapture+_2019-12-08-13-07-24.pngCapture+_2019-12-08-13-07-44.pngCapture+_2019-12-08-13-08-01.pngCapture+_2019-12-08-13-10-04.pngCapture+_2019-12-08-13-11-13.pngCapture+_2019-12-08-13-19-31.png
Galing po sa FE ITPEC exam ung pinagagawa samin. Salamat po sa tutulong
 

Arcturus

Forum Guru
eto 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();
    }
}
 
Comment

Heathcliff

Honorary Poster
eto 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();
    }
}
maraming salamat po sir! pagaralan ko po yan
 
Comment

pixkit

Addict
No need to wait for your prof to teach you Java.

Your best bet is to research Java online (like what you are doing here in the forums) but also take a look at the online articles and tutorials and videos (i.e in YôùTùbé).
 
Comment

Popular This Month

Online statistics

Members online
1,094
Guests online
892
Total visitors
1,986

Forum statistics

Threads
780,880
Messages
15,444,175
Members
1,418,191
Top