Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Part Time Full Time
- public class fullTimePartTime {
- public static void main(String[] args) {
- Scanner input = new Scanner(System.in);
- //Initiation of Variables
- String name, partTimeorFullTime;
- double basicPay, rate, otPay, grossPay;
- int nHours, nOvertime;
- System.out.print("Enter Employee Name: ");
- name = input.nextLine(); //get name
- System.out.print("Press F for Full time or P for Part time: ");
- partTimeorFullTime = input.nextLine(); // get F or P
- if(partTimeorFullTime.equalsIgnoreCase("F")){ //if F yung binigay, do this
- System.out.println("-------Full Time Employee-------");
- System.out.print("Enter Basic Pay: ");
- basicPay = input.nextDouble();
- System.out.println("-------------------------");
- System.out.println("Employee Name: " + name);
- System.out.println("Basic Pay: " + basicPay );
- System.out.println("");
- System.out.println("-----------------------");
- System.out.println("Gross Pay: " + basicPay);
- }else if(partTimeorFullTime.equalsIgnoreCase("p")){ //if P yung binigay, do this
- System.out.println("----Part Time Employee----");
- System.out.print("Enter rate per hour: ");
- rate = input.nextDouble();
- System.out.print("Enter no. of hours worked: ");
- nHours = input.nextInt();
- System.out.print("Enter no. of overtime: ");
- nOvertime = input.nextInt();
- basicPay = rate * nHours;
- otPay = nOvertime * (rate * 1.25);
- grossPay = basicPay + otPay;
- System.out.println("------------------------");
- System.out.println("Employee Name: " + name);
- System.out.println("Basic Pay: " + basicPay);
- System.out.println("Overtime Pay: " + otPay);
- System.out.println("");
- System.out.println("----------------------");
- System.out.println("Gross Pay: " + grossPay);
- }else if(!partTimeorFullTime.equalsIgnoreCase("p") && !partTimeorFullTime.equalsIgnoreCase("f")){
- // If neither p or f, do this
- System.out.println("Error");
- }
- }
- }
- //Factorial Calculator
- public class calculatFactorial {
- public static void main(String[] args) {
- Scanner input = new Scanner(System.in);
- System.out.println("------Factorial Calculator-------");
- int number, counter;
- for(counter = 0; counter < 5; counter++){
- // for loop para limang beses mag run yung program
- System.out.print("Enter a positive integer: ");
- number = input.nextInt();
- // if yung number is less than zero, mag error.
- if(number < 0){
- System.out.println("Invalid input! Program stopped! ");
- break;
- }else{
- System.out.print(number + "! = ");
- int num, product = 1;
- for(num = 1; num <= number; num++){
- //for loop para makuha yung numbers below the inputted number
- if(num == 1){
- System.out.print(num);
- }else{
- System.out.print(" x " + num);
- }
- //to get the factorial or the product of all the numbers
- product = product * num;
- }
- System.out.println("");
- System.out.println("The factorial of " + number +" is: " + product);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement