Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/393.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在java中,如何从一个Mutator/Setter调用另一个Mutator/Setter?_Java - Fatal编程技术网

在java中,如何从一个Mutator/Setter调用另一个Mutator/Setter?

在java中,如何从一个Mutator/Setter调用另一个Mutator/Setter?,java,Java,在main方法中只执行一次“FinalProject output=newfinalproject();” Please check carefully that, you have initiate multiple "FinalProject" object, 请在此处查找代码- /*---------------最后一个项目课开始-----------*/ 封装测试栈; 公共类最终项目 { //-------------------------------属性---------

在main方法中只执行一次“FinalProject output=newfinalproject();”

    Please check carefully that, you have initiate multiple "FinalProject" object, 
请在此处查找代码-
/*---------------最后一个项目课开始-----------*/
封装测试栈;
公共类最终项目
{
//-------------------------------属性--------------------------------
公共字符串名称;
公共双法庭;
公共选择;
公共双温;
公共双薪;
公共双薪2;
公共双薪3;
公开双股;
公共双hdmf;
公共双sss;
公共双重税;
公共双基本法;
公共双网支付;
//-------------------------------建造师--------------------------------
公共财政项目(){
此。名称=”;
这个cout=0.0;
该温度=0.0;
这个选项=0;
此值为0.0;
这意味着工资=0.0;
这个.salary2=薪水;
这意味着工资3=0.0;
这个.份额=0.0;
该值为.hdmf=0.0;
这表明,sss=0.0;
此项税收=0.0;
这是0.netpay=0.0;
}  
//-------------------------------塞特--------------------------------
公共void集合名(字符串名){
this.name=name;
}
公共无效设置(双薪){
如果(工资<30000.00){
System.out.print(“\n-------------------\n结果:”);
System.out.print(“\n您的职位是员工”+“\n”);
}
否则,如果(工资>=30000.00,工资=50000.00,工资=80000.00,工资100001.00){
System.out.print(“\n-------------------\n结果:”);
系统输出打印(“\n您的职位是高级官员”+“\n”);
}
//薪水=工资;
}
公共void setChoice(int-choice){
这个。选择=选择;
}
公共无效回退基准(双基准基准){
this.basicsalary=basicsalary;
}
公共网络支付(双倍网络支付){
netpay=-this.salary-this.hdmf-this.salary3-this.tax;
这个.netpay=netpay;
}
公共收入(双倍工资){
如果(工资=9000&&salary=10000&&salary=11000&&salary=12000&&salary=14000&&salary=15000&&salary=16000&&salary=17000&&salary=18000&&salary=19000&&salary=20000&&salary=21000&&salary=22000&&salary=23000&&salary=24000&&salary=25000&&salary=26000&&salary=27000&&salary=27000&&salary)=28000&&salary=29000&&salary=30000&&salary=31000&&salary=32000&&salary=33000&&salary=34000&&salary=35000)
{
工资=437.50;
}
这个。薪水=薪水;
}公共收入2(双薪2){
这个。salary2=salary2;
}
公共无效温度(双温度){
这个.temp=temp;
}
公共收入3(双薪3){
如果(本月工资3<30000){
薪水3=薪水3*0.05;
}
否则如果(this.salary3>=30000&&this.salary3=50000&&this.salary3=80000&&this.salary3 100001){
薪水3=薪水3*0.15;
}
这个。薪水3=薪水3;
}
公开无效股份(双股){
这个。分享=分享;
}
公共无效设置(双临时){
这个.temp=temp;
}
公共无效设置hdmf(双hdmf){
如果(hdmf>100){
System.out.print(“已输入首选HDMF值”+“\n”);
this.hdmf=hdmf;
}
否则如果(hdmf==0){
System.out.print(“已选择默认值扣除100 HDMF”+“\n”);
工资2=100.00;
this.hdmf=薪水2;
}
}
公共安全系统(双安全系统){
该值为0.sss=sss*0.50;
}
公共税(双重税){
该税=税*0.50;
}
//吸气剂
公共字符串getName(){
返回此.name;
}
公共双getCout(){
把这个还给我;
}
public int getChoice(){
返回此选项;
}
公共双getBasicsalary(){
归还这个。基本日历;
}
公共双getNetpay(){
将此邮件寄回.netpay;
}
公共双薪制{
退还此工资;
}
公共双getTemp(){
返回此.temp;
}
公共双职工薪酬2(){
归还这个。薪水2;
}
公共双职工薪酬3(){
归还这个。薪水3;
}
公共双getShare(){
把这一份还给我;
}
公共双getHdmf(){
返回此.hdmf;
}
公共双getSss(){
返回此.sss;
}
公共双getTax(){
退还此税;
}
}
/*---------------最终项目类结束-----------*/
/*---------------FinalProjectMain类开始--------*/
封装测试栈;
导入java.util.Scanner;
公共类最终项目{
公共静态void main(字符串[]args)
{
试一试{
扫描仪输入=新扫描仪(System.in);
最终项目输出=新的最终项目();
System.out.print(“您好,先生/女士,谢谢您的帮助我们的程序要求您多次输入您的(基本工资),以便我们计算您的净工资”);
System.out.print(“\n先生,祝您愉快。\n\n\n”);
系统输出打印(“输入员工姓名:”);
output.setName(input.nextLine());
系统输出打印(“输入您的基本工资:”;
output.setBasicsalary(input.nextDouble());
System.out.print(“请再次输入您的基本工资以计算philhealth供款:”);
output.setSalary(input.nextDouble());
System.out.print(“请再次输入您的基本工资以计算hdmf:”);
output.setSalary2(input.nextDouble());
System.out.print(“请输入要共享的HDMF数量:\n否则输入0以扣除默认的100 HDMF份额:\n”);
output.setHdmf(input.nextDouble());
System.out.print(“请再次输入您的基本工资,以扣除您工资中的SSS:”);
output.setSalary3(input.nextDouble());
System.out.print(“\n\nSS扣减为:”+output.getSalary3());
系统输出打印(“\n”);
System.out.print(“(请输入SSS duductio
package finalproject;

import java.util.Scanner;

public class FinalProjectMain {

    public static void main(String[] args) 
    {

        Scanner input = new Scanner(System.in);

        FinalProject output1 = new FinalProject();//name
        FinalProject output2 = new FinalProject();//share
        FinalProject output3 = new FinalProject(); //hdmf //salary2
        FinalProject output4 = new FinalProject();//sss
        FinalProject output5 = new FinalProject();//position
        FinalProject output6 = new FinalProject();//tax
        FinalProject output7 = new FinalProject();//Basicsalary
        FinalProject output8 = new FinalProject();//netpay

       FinalProject output = new FinalProject();


        System.out.print("Good day! To you Sir/ma`am Thanks for helping me our program requires you to input your (basic salary) multiple times in order for us to compute your netpay");
        System.out.print("\n");
        System.out.print("Thank you Sir Have a Good day.");

           System.out.print("\n");
              System.out.print("\n");
                 System.out.print("\n");
                    System.out.print("\n");
                       System.out.print("\n");


        System.out.print("Enter Employee name: ");
        output1.setName(input.nextLine());

        System.out.print("Enter your basic salary: ");
        output7.setBasicsalary(input.nextDouble());

        System.out.print("Please Enter Your basic salary again to compute the philhealth contribution: ");
        output2.setSalary(input.nextDouble());

        System.out.print("Please Enter your basic salary again to compute the hdmf: ");
        output3.setSalary2(input.nextDouble());

        System.out.print("Please Enter the amount of HDMF you want to share: \n otherwise Enter 0 to deduct the default 100 HDMF share: \n");
        output3.setHdmf(input.nextDouble());

        System.out.print("Please Enter your basic salary again to deduct the SSS in your salary: ");
        output4.setSalary3(input.nextDouble());

        System.out.print("\n\nSSS deduction is: " + output4.getSalary3());
        System.out.print("\n");

        System.out.print("(Please Enter the SSS duduction value above to compute the your tax): ");
        output6.setTax(input.nextDouble());

        System.out.print("Please Enter again your basic salary to compute your netpay: ");
        output8.setNetpay(input.nextDouble());

        System.out.print("Enter your basic salary again to determine your position: ");
        output5.setCout(input.nextDouble());




         System.out.print("Employee name is: " + output1.getName());
         System.out.print("\n");

         System.out.print("Your basic salary is: " + output7.getBasicsalary());
         System.out.print("\n");

         System.out.print("Philhealth contribution is: " + output2.getSalary());
         System.out.print("\n");

         System.out.print("Your HDMF share is: " + output3.getHdmf());
         System.out.print("\n");
         System.out.print("SSS deduction is: " + output4.getSalary3());
         System.out.print("\n");
         System.out.print("Your deduction Tax is: " + output6.getTax());
         System.out.print("\n");
         System.out.print("Your netpay is: " + output8.getNetpay());



    }
}
    Please check carefully that, you have initiate multiple "FinalProject" object, 
    please find code here - 

    /*--------------- FinalProject Class Begin ------------ */
    package teststack;

    public class FinalProject

    {

    //------------------------------- Attributes --------------------------------

    public String name;
    public double cout;
    public int choice;
    public Double temp;
    public Double salary;
    public  Double salary2;
    public  Double salary3;  
    public Double share;
    public Double hdmf;
    public Double sss;
    public Double tax;
    public Double basicsalary;
    public Double netpay;

    //------------------------------- Constructor --------------------------------

    public FinalProject (){

    this.name="";
    this.cout=0.0;
    this.temp=0.0;
    this.choice = 0;
    this.basicsalary = 0.0;
    this.salary=0.0;
    this.salary2=salary;
    this.salary3=0.0;
    this.share=0.0;
    this.hdmf=0.0;
    this.sss=0.0;
    this.tax=0.0;   
    this.netpay = 0.0;
    }  

    //------------------------------- Setter --------------------------------

    public void setName(String name){

    this.name=name;

    }

    public void setCout(Double salary){

    if (salary < 30000.00){
          System.out.print("\n ----------------- \n RESULT:"); 
       System.out.print("\nYour Position is Staff" + "\n");
    }

    else if (salary >= 30000.00 && salary <= 49999.00){
          System.out.print("\n ----------------- \n RESULT:"); 
        System.out.print("\nYour Position is Supervisor"+ "\n");
    }

    else if (salary >= 50000.00 && salary <= 79999.00){
          System.out.print("\n ----------------- \n RESULT:"); 
        System.out.print("\nYour Position is Manager"+ "\n");
    }

     else if (salary >= 80000.00 && salary <= 100000.00){
           System.out.print("\n ----------------- \n RESULT:"); 
        System.out.print("\nYour Position is Junior Officer"+ "\n");
    }

     else if (salary > 100001.00){
           System.out.print("\n ----------------- \n RESULT:"); 
        System.out.print("\nYour Position is Senior Officer"+ "\n");
    }

    // salary = cout;

    }

    public void setChoice(int choice){

    this.choice=choice;

    }

    public void setBasicsalary(Double basicsalary){

    this.basicsalary = basicsalary;

    }

    public void setNetpay(Double netpay){

    netpay = -this.salary - this.hdmf - this.salary3 - this.tax;
            this.netpay=netpay;

    }

    public void setSalary(Double salary){

    if(salary <= 8999.99 )
        {
            salary = 100.00;

        }

    else if(salary >= 9000 && salary <= 9999.99)
    {
        salary = 112.50;

    }

    else if(salary >= 10000 && salary <= 10999.99)
    {
        salary = 125.00;

    }

    else if(salary >= 11000 && salary <= 11999.99)
    {
        salary = 137.50;

    }

    else if(salary >= 12000 && salary <= 12999.99)
    {
        salary = 150.00;

    }

    else if(salary >= 13000 && salary <= 13999.99)
    {
        salary = 162.50;

    }

    else if(salary >= 14000 && salary <= 14999.99)
    {
        salary = 175.50;

    }

    else if(salary >= 15000 && salary <= 15999.99)
    {
        salary = 187.50;

    }

    else if(salary >= 16000 && salary <= 16999.99)
    {
        salary = 200.00;

    }

    else if(salary >= 17000 && salary <= 17999.99)
    {
        salary = 212.50;

    }

    else if(salary >= 18000 && salary <= 18999.99)
    {
        salary = 225.00;

    }

    else if(salary >= 19000 && salary <= 19999.99)
    {
        salary = 237.50;

    }

    else if(salary >= 20000 && salary <= 20999.99)
    {
        salary = 250.00;

    }

    else if(salary >= 21000 && salary <= 21999.99)
    {
        salary = 262.50;

    }

    else if(salary >= 22000 && salary <= 22999.99)
    {
        salary = 275.00;

    }

    else if(salary >= 23000 && salary <= 23999.99)
    {
        salary = 287.50;

    }

    else if(salary >= 24000 && salary <= 24999.99)
    {
        salary = 300.00;

    }

    else if(salary >= 25000 && salary <= 25999.99)
    {
        salary = 312.50;

    }

    else if(salary >= 26000 && salary <= 26999.99)
    {
        salary = 325.00;

    }

    else if(salary >= 27000 && salary <= 27999.99)
    {
        salary = 337.50;

    }

    else if(salary >= 28000 && salary <= 28999.99)
    {
        salary = 350.00;

    }

    else if(salary >= 29000 && salary <= 29999.99)
    {
        salary = 362.50;

    }

    else if(salary >= 30000 && salary <= 30999.99)
    {
        salary = 375.00;

    }

    else if(salary >= 31000 && salary <= 31999.99)
    {
        salary = 387.50;

    }

    else if(salary >= 32000 && salary <= 32999.99)
    {
        salary = 400.00;

    }

    else if(salary >= 33000 && salary <= 33999.99)
    {
        salary = 412.50;

    }

    else if(salary >= 34000 && salary <= 34999.99)
    {
        salary = 425.00;

    }

    else if(salary >= 35000)
    {
        salary = 437.50;

    }

    this.salary=salary;

    } public void setSalary2(Double salary2){

    this.salary2=salary2;

    }

    public void temp(Double temp){

    this.temp=temp;

    }

    public void setSalary3(Double salary3){

     if(this.salary3 < 30000){
       salary3 = salary3 * 0.05;
    }

    else if (this.salary3 >= 30000 && this.salary3 <= 49999){
       salary3 = salary3 * 0.07;
    }

    else if (this.salary3 >= 50000 && this.salary3 <= 79999){
        salary3 = salary3 * 0.08;
    }

     else if (this.salary3 >= 80000 && this.salary3 <= 100000){
         salary3 =salary3 * 0.1;
    }

     else if (this.salary3 > 100001){
        salary3 = salary3 * 0.15;
    }


    this.salary3=salary3;

    }

    public void setShare(Double share){

    this.share=share;

    }

    public void setTemp(Double temp){

    this.temp=temp;

    }

    public void setHdmf(Double hdmf){

    if(hdmf > 100){
            System.out.print("Prefered HDMF value has been entered" + "\n");

              this.hdmf = hdmf;

        }
        else if(hdmf == 0){
            System.out.print("Default has been chosen to deduct 100 HDMF" + "\n");
            salary2 = 100.00;
             this.hdmf = salary2;
        }

    }

    public void setSss(Double sss){

    this.sss = sss * 0.50;   

    }

    public void setTax(Double tax){

    this.tax = tax * 0.50;

    }

    //getter

    public String getName(){

    return this.name;

    }

    public Double getCout(){

    return this.cout;

    }

    public int getChoice(){

    return this.choice;

    }

    public Double getBasicsalary(){

    return this.basicsalary;

    }

    public Double getNetpay(){

    return this.netpay;

    }

    public Double getSalary(){

    return this.salary;

    }

    public Double getTemp(){

    return this.temp;

    }

    public Double getSalary2(){

    return this.salary2;

    }

    public Double getSalary3(){

    return this.salary3;

    }

    public Double getShare(){

    return this.share;

    }

    public Double getHdmf(){

    return this.hdmf;

    }

    public Double getSss(){

    return this.sss;

    }

    public Double getTax(){

    return this.tax;

    }

    }

    /*--------------- FinalProject Class End ------------ */

    /*--------------- FinalProjectMain Class Begin ------------ */

    package teststack;

import java.util.Scanner;


public class FinalProjectMain {

public static void main(String[] args) 
{

    try{
    Scanner input = new Scanner(System.in);
    FinalProject output = new FinalProject();


    System.out.print("Good day! To you Sir/ma`am Thanks for helping me our program requires you to input your (basic salary) multiple times in order for us to compute your netpay");
    System.out.print("\nThank you Sir Have a Good day.\n\n\n");
    System.out.print("Enter Employee name: ");
    output.setName(input.nextLine());

    System.out.print("Enter your basic salary: ");
    output.setBasicsalary(input.nextDouble());

    System.out.print("Please Enter Your basic salary again to compute the philhealth contribution: ");
    output.setSalary(input.nextDouble());

    System.out.print("Please Enter your basic salary again to compute the hdmf: ");
    output.setSalary2(input.nextDouble());

    System.out.print("Please Enter the amount of HDMF you want to share: \n otherwise Enter 0 to deduct the default 100 HDMF share: \n");
    output.setHdmf(input.nextDouble());

    System.out.print("Please Enter your basic salary again to deduct the SSS in your salary: ");
    output.setSalary3(input.nextDouble());

    System.out.print("\n\nSSS deduction is: " + output.getSalary3());
    System.out.print("\n");

    System.out.print("(Please Enter the SSS duduction value above to compute the your tax): ");
    output.setTax(input.nextDouble());

    System.out.print("Please Enter again your basic salary to compute your netpay: ");
    output.setNetpay(input.nextDouble());

    System.out.print("Enter your basic salary again to determine your position: ");
    output.setCout(input.nextDouble());

     System.out.print("Employee name is: " + output.getName());
     System.out.print("\n");

     System.out.print("Your basic salary is: " + output.getBasicsalary());
     System.out.print("\n");

     System.out.print("Philhealth contribution is: " + output.getSalary());
     System.out.print("\n");

     System.out.print("Your HDMF share is: " + output.getHdmf());
     System.out.print("\n");
     System.out.print("SSS deduction is: " + output.getSalary3());
     System.out.print("\n");
     System.out.print("Your deduction Tax is: " + output.getTax());
     System.out.print("\n");
     System.out.print("Your netpay is: " + output.getNetpay());
    } catch (Exception e){
        System.out.println("ex : "+e);
    }


}

}

    /*--------------- FinalProjectMain Class End ------------ */