Advertisement
angeloeboy10

Full Time Part Time

Dec 8th, 2020 (edited)
1,056
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.66 KB | None | 0 0
  1. //Part Time Full Time
  2. public class fullTimePartTime {
  3.     public static void main(String[] args) {
  4.        
  5.         Scanner input = new Scanner(System.in);
  6.         //Initiation of Variables
  7.         String name, partTimeorFullTime;
  8.         double basicPay, rate, otPay, grossPay;
  9.         int nHours, nOvertime;
  10.  
  11.  
  12.         System.out.print("Enter Employee Name: ");
  13.         name = input.nextLine(); //get name
  14.         System.out.print("Press F for Full time or P for Part time: ");
  15.         partTimeorFullTime = input.nextLine(); // get F or P
  16.  
  17.         if(partTimeorFullTime.equalsIgnoreCase("F")){ //if F yung binigay, do this
  18.  
  19.             System.out.println("-------Full Time Employee-------");
  20.             System.out.print("Enter Basic Pay: ");
  21.             basicPay = input.nextDouble();
  22.             System.out.println("-------------------------");
  23.             System.out.println("Employee Name: " + name);
  24.             System.out.println("Basic Pay: " + basicPay );
  25.             System.out.println("");
  26.             System.out.println("-----------------------");
  27.             System.out.println("Gross Pay: " + basicPay);
  28.  
  29.         }else if(partTimeorFullTime.equalsIgnoreCase("p")){ //if P yung binigay, do this
  30.  
  31.  
  32.             System.out.println("----Part Time Employee----");
  33.             System.out.print("Enter rate per hour: ");
  34.             rate = input.nextDouble();
  35.             System.out.print("Enter no. of hours worked: ");
  36.             nHours = input.nextInt();
  37.             System.out.print("Enter no. of overtime: ");
  38.             nOvertime = input.nextInt();
  39.             basicPay = rate * nHours;
  40.             otPay = nOvertime * (rate * 1.25);
  41.             grossPay = basicPay + otPay;
  42.             System.out.println("------------------------");
  43.             System.out.println("Employee Name: " + name);
  44.             System.out.println("Basic Pay: " + basicPay);
  45.             System.out.println("Overtime Pay: " + otPay);
  46.             System.out.println("");
  47.             System.out.println("----------------------");
  48.             System.out.println("Gross Pay: " + grossPay);
  49.  
  50.         }else if(!partTimeorFullTime.equalsIgnoreCase("p") && !partTimeorFullTime.equalsIgnoreCase("f")){
  51.             // If neither p or f, do this
  52.             System.out.println("Error");
  53.         }
  54.     }
  55. }
  56.  
  57.  
  58.  
  59. //Factorial Calculator
  60.  
  61. public class calculatFactorial {
  62.     public static void main(String[] args) {
  63.         Scanner input = new Scanner(System.in);
  64.  
  65.         System.out.println("------Factorial Calculator-------");
  66.         int number, counter;
  67.  
  68.         for(counter = 0; counter < 5; counter++){
  69.             // for loop para limang beses mag run yung program
  70.    
  71.             System.out.print("Enter a positive integer: ");
  72.             number = input.nextInt();
  73.            
  74.             // if yung number is less than zero, mag error.
  75.             if(number < 0){
  76.                 System.out.println("Invalid input! Program stopped! ");
  77.                 break;
  78.  
  79.             }else{
  80.                 System.out.print(number + "! = ");
  81.                 int num, product = 1;
  82.            
  83.                 for(num = 1; num <= number; num++){
  84.                     //for loop para makuha yung numbers below the inputted number
  85.                    
  86.                     if(num == 1){
  87.                         System.out.print(num);
  88.                     }else{
  89.                         System.out.print(" x " + num);
  90.                     }
  91.                    
  92.                     //to get the factorial or the product of all the numbers
  93.                     product = product * num;
  94.                 }
  95.  
  96.                 System.out.println("");
  97.                 System.out.println("The factorial of " + number +" is: " + product);
  98.             }
  99.         }
  100.     }
  101. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement