Advertisement
Guest User

Untitled

a guest
Dec 5th, 2016
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.93 KB | None | 0 0
  1. import java.util.*;
  2.  
  3. class Math{
  4.    
  5.     public static void main(String[] p){
  6.         bonus b1 = new bonus();
  7.         int total;
  8.        
  9.        
  10.        
  11.         introduction();   //This is the introduction method which would tell the user what the program does
  12.         b1 = createRecord(b1);  // Here i create the record which holds the two values of the profit and work done
  13.        
  14.         total = calculation(b1); // The record is passed into here and it would total up the two values to give another value out of 10
  15.         finalCalc(total); // This creates a
  16.     }
  17.        
  18.        
  19.        
  20.        
  21.        
  22.     public static void introduction(){
  23.        
  24.         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.");
  25.        
  26.     }
  27.    
  28.    
  29.    
  30.    
  31.    
  32.    
  33.     public static int calculation(bonus b1){
  34.         int total;
  35.        
  36.         total = calcWork(b1)+calcProfit(b1);
  37.         total = total/7;
  38.        
  39.         return total;
  40.        
  41.     }
  42.    
  43.     public static void finalCalc(int total){
  44.         int amountPaid=total*5000;   // This calculates how much the employee would be paid
  45.         System.out.println("Your performance score is "+total+"/10");
  46.         System.out.println("You will be paid "+amountPaid);
  47.    
  48.     }
  49.    
  50.    
  51.    
  52.    
  53.     // --------- These methods are here to calculate and return the two different values
  54.     public static int calcProfit(bonus b1){
  55.         int profit = getProfit(b1)*2;
  56.         return profit;
  57.     }
  58.    
  59.    
  60.     public static int calcWork(bonus b1){
  61.         int work = getWork(b1)*5;
  62.         return work;
  63.     }
  64.     // -----------------------------------------------------------------------------------
  65.  
  66.    
  67.    
  68.    
  69.    
  70.    
  71.     // Creation of the record  ----- Here two values are going to be placed in a single record
  72.     public static bonus createRecord(bonus b1){
  73.        
  74.         int profit;
  75.         int work;
  76.    
  77.         System.out.println("Please enter the amount of profit made");
  78.         Scanner scanner = new Scanner(System.in);
  79.         profit = scanner.nextInt();
  80.        
  81.         System.out.println("Please enter the amount of work done");
  82.         Scanner scanner2 = new Scanner(System.in);
  83.         work = scanner.nextInt();
  84.        
  85.        
  86.         b1 = setProfit(b1, profit);
  87.         b1 = setWork(b1, work);
  88.        
  89.         return b1;
  90.     }
  91.    
  92.  
  93.     // Start of getters & setters
  94.    
  95.     public static bonus setProfit(bonus b, int profit){
  96.         b.profit = profit;
  97.         return b;
  98.     }
  99.     public static bonus setWork(bonus b, int work){
  100.         b.work = work;
  101.         return b;
  102.     }
  103.    
  104.     public static int getProfit(bonus b){
  105.         return b.profit;
  106.     }
  107.     public static int getWork(bonus b){
  108.         return b.work;
  109.     }
  110.    
  111.     // End of getters & setters  
  112.    
  113.  
  114. }
  115.  
  116.  
  117.  
  118.  
  119. class bonus{
  120.     int profit;
  121.     int work;
  122. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement