Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- class Math{
- public static void main(String[] p){
- bonus b1 = new bonus();
- int total;
- introduction(); //This is the introduction method which would tell the user what the program does
- b1 = createRecord(b1); // Here i create the record which holds the two values of the profit and work done
- total = calculation(b1); // The record is passed into here and it would total up the two values to give another value out of 10
- finalCalc(total); // This creates a
- }
- public static void introduction(){
- System.out.println("This program will allow you to enter two different values, profit and hard-work, in order to assess the amount of bonus given.");
- }
- public static int calculation(bonus b1){
- int total;
- total = calcWork(b1)+calcProfit(b1);
- total = total/7;
- return total;
- }
- public static void finalCalc(int total){
- int amountPaid=total*5000; // This calculates how much the employee would be paid
- System.out.println("Your performance score is "+total+"/10");
- System.out.println("You will be paid "+amountPaid);
- }
- // --------- These methods are here to calculate and return the two different values
- public static int calcProfit(bonus b1){
- int profit = getProfit(b1)*2;
- return profit;
- }
- public static int calcWork(bonus b1){
- int work = getWork(b1)*5;
- return work;
- }
- // -----------------------------------------------------------------------------------
- // Creation of the record ----- Here two values are going to be placed in a single record
- public static bonus createRecord(bonus b1){
- int profit;
- int work;
- System.out.println("Please enter the amount of profit made");
- Scanner scanner = new Scanner(System.in);
- profit = scanner.nextInt();
- System.out.println("Please enter the amount of work done");
- Scanner scanner2 = new Scanner(System.in);
- work = scanner.nextInt();
- b1 = setProfit(b1, profit);
- b1 = setWork(b1, work);
- return b1;
- }
- // Start of getters & setters
- public static bonus setProfit(bonus b, int profit){
- b.profit = profit;
- return b;
- }
- public static bonus setWork(bonus b, int work){
- b.work = work;
- return b;
- }
- public static int getProfit(bonus b){
- return b.profit;
- }
- public static int getWork(bonus b){
- return b.work;
- }
- // End of getters & setters
- }
- class bonus{
- int profit;
- int work;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement