如何将ADT纳入此计划

时间:2016-11-29 15:45:11

标签: java methods adt

我有一个任务是编写一个程序,它获取一个利润分数并将其乘以2,得到努力工作得分并乘以5,将两者加在一起,除以7然后乘以5000得到一个& #34;奖金"

这将非常简单,但规范声明我必须使用至少9种方法,不包括main,use函数和getter / setter方法。其余的我可以做,但我不知道如何在这样的程序中使用ADT。

这是我到目前为止所做的......它做了它应该做的但是它缺少了ADT。

    import java.util.Scanner;

class bonus {
    public static void main(String[] args) {
       int i1 = inputProfit();
       int w1 = inputWork();
       int p1 = performanceScore(i1, w1);
       int f1 = finalbonus(p1);
       output(f1);

        System.exit(0);
    }//end main method

    public static int inputProfit() {
        Scanner scanner = new Scanner(System.in);
        System.out.println("Profit score?");
        int profitScore = scanner.nextInt();
        return profitScore;

    }

    public static int inputWork() {
        Scanner scanner1 = new Scanner(System.in);
        System.out.println("Hard work score?");
        int workScore = scanner1.nextInt();
        return workScore;
    }

    public static int profit(int profitScore) {
        profitScore = profitScore*2;
        return profitScore;
    }

    public static int work(int workScore) {
        workScore = workScore*5;
        return workScore;
    }

    public static int performanceScore(int profitScore, int workScore) {
        int p = profit(profitScore);
        int w = work(workScore);
        int performance = ((p + w)/7);
        return performance;
    }

    public static int finalbonus(int performance) {
        int payOut = performance * 5000 ;
        return payOut;
    }

    public static void output(int payOut) {
        System.out.println("Your bonus is " + payOut + " pounds");
    }


}//end class bonus    

0 个答案:

没有答案