0% found this document useful (0 votes)
20 views14 pages

CODER

The document outlines a Java program that calculates employee salaries and deductions, displaying payslips and payment methods for a hotel service. It includes classes for different types of employees, amenities, and room selections, along with methods for calculating total salaries and deductions. The program also handles user input for employee details and amenity selections, providing a structured approach to managing employee compensation and hotel services.

Uploaded by

jhndmtvd
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views14 pages

CODER

The document outlines a Java program that calculates employee salaries and deductions, displaying payslips and payment methods for a hotel service. It includes classes for different types of employees, amenities, and room selections, along with methods for calculating total salaries and deductions. The program also handles user input for employee details and amenity selections, providing a structured approach to managing employee compensation and hotel services.

Uploaded by

jhndmtvd
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 14

8 @Override

double calculateDeductions() {
return sssDeduction + taxDeduction +
pagibigDeduction + philhealthDeduction;
}
@Override
void displayPayslip(){}
@Override
void displayPay() {
double totalSalary = calculateTotalSalary();
double totalDeductions =
calculateDeductions();
double netPay = totalSalary - totalDeductions;
System.out.println("Name: " + name);
System.out.println("Employee Number: " +
employeeNumber);
System.out.println("TIN: " + TIN);
System.out.println("Basic Salary: " +
basicSalary);
System.out.println("Incentives:");
System.out.println("Internet: " +
internetAllowance);
System.out.println("Transport: " +
transpoAllowance);
System.out.println("Rice Allowance: " +
riceAllowance);
System.out.println("Total Salary: " +
totalSalary);
System.out.println("\nDeductions:");
System.out.println("SSS: " + sssDeduction);
System.out.println("Tax: " + taxDeduction);
System.out.println("Pag-ibig: " +
pagibigDeduction);
System.out.println("PhilHealth: " +
philhealthDeduction);
System.out.println("Total Deductions: " +
totalDeductions);
System.out.println("\nyour amount: " +
netPay);
}
}
package main; System.out.println("Name: " + name); 8
abstract class Employe { System.out.println("Employee Number: " +
employeeNumber);
protected String name;
System.out.println("TIN: " + TIN);
protected String employeeNumber;
System.out.println("Basic Salary: " + basicSalary);
protected String TIN;
System.out.println("Incentives:");
protected final double basicSalary = 20000;
System.out.println("Internet: " + internetAllowance);
public Employe(String name, String
employeeNumber, String TIN) { System.out.println("Transport: " +
transpoAllowance);
this.name = name;
System.out.println("Rice Allowance: " +
this.employeeNumber = employeeNumber;
riceAllowance);
this.TIN = TIN;
System.out.println("Total Salary: " + totalSalary);
}
System.out.println("\nDeductions:");
abstract double calculateTotalSalary();
System.out.println("SSS: " + sssDeduction);
abstract double calculateDeductions();
System.out.println("Tax: " + taxDeduction);
abstract void displayPayslip();
System.out.println("Pag-ibig: " + pagibigDeduction);
abstract void displayPay();
System.out.println("PhilHealth: " +
} philhealthDeduction);

System.out.println("Total Deductions: " +


totalDeductions);
package main;
System.out.println("\nyour amount: " + netPay);
public class FullTimeEmployee extends Employe {
}
private final double internetAllowance = 1000;
}
private final double transpoAllowance = 3500;

private final double riceAllowance = 2500;


package main;
private final double sssDeduction = 1000;
public class FullTimeEmployee2 extends Employe {
private final double taxDeduction = 500;
private final double internetAllowance = 50000;
private final double pagibigDeduction = 100;
private final double transpoAllowance = 4800;
private final double philhealthDeduction = 200;
private final double riceAllowance = 5000;
public FullTimeEmployee(String name, String
employeeNumber, String TIN) { private final double sssDeduction = 1000;
super(name, employeeNumber, TIN); private final double taxDeduction = 500;
} private final double pagibigDeduction = 100;
@Override private final double philhealthDeduction = 200;
double calculateTotalSalary() {

return basicSalary + internetAllowance +


transpoAllowance + riceAllowance;
public FullTimeEmployee2(String name, String
} employeeNumber, String TIN) {

@Override super(name, employeeNumber, TIN);

void displayPay(){} }

@Override @Override

void displayPayslip() { double calculateTotalSalary() {

double totalSalary = calculateTotalSalary(); return basicSalary + internetAllowance +


transpoAllowance + riceAllowance;
double totalDeductions = calculateDeductions();
}
double netPay = totalSalary - totalDeductions;
public String getName() { package main; 8
7
return name; import java.util.Scanner;

} public class Main {

} public static void main(String[] args) {

class Spa extends Amenity { Scanner scanner = new Scanner(System.in);

public Spa() { System.out.println("Enter details of Employee");

super("Spa Service", 3400.00); System.out.print("Name: ");

} String name1 = scanner.nextLine();

System.out.print("Employee Number: ");


}
String empNum1 = scanner.nextLine();
class Gym extends Amenity {
System.out.print("TIN: ");
public Gym() {
String tin1 = scanner.nextLine();
super("Gym Access", 2500.00);
Employe emp1 = new FullTimeEmployee(name1,
}
empNum1, tin1);
}
System.out.println("\n----------------------------");
class Pool extends Amenity { emp1.displayPayslip();
public Pool() { while (true) {
super("Pool Access", 1500.00); System.out.print("\nWould you want to check
} Highest employee account? (yes/no): ");

} String again = scanner.nextLine().toLowerCase();

if (again.equals("yes")) {

System.out.println("Enter details of Highest


Employee");

System.out.print("Name: ");

String name2 = scanner.nextLine();

System.out.print("Employee Number: ");

String empNum2 = scanner.nextLine();

System.out.print("TIN: ");

String tin2 = scanner.nextLine();

Employe emp2 = new


FullTimeEmployee(name2, empNum2, tin2);

System.out.println("\n----------------------------");

emp2.displayPay();

} else if (again.equals("no")) {

System.out.println("Thank you!");

break;

} else {

System.out.println("Invalid input. Please enter


'yes' or 'no'.");

scanner.close();
}

}
7
case 2: }
paymentMethod = "Card Payment"; }
break; package main;
default: public class room {
System.out.println("Invalid input! Please try private String type;
again.");
private double price;
}
public room(String type, double price) {
}
this.type = type;
System.out.println("\nPayment Method: " +
this.price = price;
paymentMethod);
}
System.out.println("Thank you for staying with us!
Come back again!"); public double getPrice() {

return price;
scanner.close(); }
} public String getType() {

return type;
public static room selectRoom(Scanner scanner) { }
room room = null; }
while (room == null) { class KingRoom extends room {
System.out.println(" Welcome to my hotel public KingRoom() {
");
super("King Room", 15000.00);
System.out.println("Select a room type:");
}
System.out.println("1. Regular Room (Php3500)");
}
System.out.println("2. Family Room (Php10000)");
class FamilyRoom extends room {
System.out.println("3. King Room (Php15000)");
public FamilyRoom() {
System.out.print("Enter choice: ");
super("Family Room", 10000.00);
int roomChoice = scanner.nextInt();
}

}
switch (roomChoice) {
class RegularRoom extends room {
case 1:
public RegularRoom() {
room = new RegularRoom();
super("Regular Room", 3500.00);
break;
}
case 2:
}
room = new FamilyRoom();
package main;
break;
public class Amenity {
case 3:
private String name;
room = new KingRoom();
private double price;
break;
public Amenity(String name, double price) {
default:
this.name = name;
System.out.println("Invalid input! Please try
again."); this.price = price;

} }

} public double getPrice() {

return room; return price;


package main; default: 7

import java.util.ArrayList; System.out.println("Invalid choice! Please


try again.");
import java.util.Scanner;
}
public class Main {
}
public static void main(String[] args) {
}
Scanner scanner = new Scanner(System.in);
double totalPrice = 0;
ArrayList<room> selectedRooms = new
ArrayList<>(); System.out.println("\n -------- HOTEL RECEIPT
--------");
ArrayList<Amenity> amenities = new ArrayList<>();
for (room room : selectedRooms) {
while (true) {
System.out.printf("%-20s %10.2f%n",
room room = selectRoom(scanner);
room.getType(), room.getPrice());
selectedRooms.add(room);
totalPrice += room.getPrice();
System.out.println("\nDo you want to choose
}
another room? (yes/no)");
for (Amenity amenity : amenities) {
String anotherRoom =
scanner.next().toLowerCase(); System.out.printf("%-20s %10.2f%n",
amenity.getName(), amenity.getPrice());
if (!anotherRoom.equals("yes")) break;
totalPrice += amenity.getPrice();
}
}
System.out.println("\nDo you want to add
amenities? (yes/no)"); System.out.printf("\n%-20s %10.2f%n", "Total:",
totalPrice);
String amenityResponse =
scanner.next().toLowerCase(); String paymentMethod = "";

if (amenityResponse.equals("yes")) { while (paymentMethod.isEmpty()) {

while (true) { System.out.println("\nSelect a payment


method:");
System.out.println("\nSelect amenities:\n0.
Display Receipt"); System.out.println("1. Cash");

System.out.println("1. Spa Service (Php3400)"); System.out.println("2. Card Payment");

System.out.println("2. Gym Access (Php2500)"); System.out.print("Enter choice: ");

System.out.println("3. Pool Access (Php1500)"); int paymentChoice = scanner.nextInt();

System.out.print("Enter choice: "); switch (paymentChoice) {

int amenityChoice = scanner.nextInt(); case 1:

if (amenityChoice == 0) break; paymentMethod = "Cash";

switch (amenityChoice) { break;

case 1: case 2:

amenities.add(new Spa()); paymentMethod = "Card Payment";

break; break;

case 2: System.out.print("Enter choice: ");

amenities.add(new Gym()); int paymentChoice = scanner.nextInt();

break; switch (paymentChoice) {

case 3: case 1:

amenities.add(new Pool()); paymentMethod = "Cash";

break; break;
public Drinks(String name, double price, int package main; 6
quantity) {
public class Desserts {
this.name = name;
private String name;
this.price = price;
private double price;
this.quantity = quantity;
private int quantity;
}
public Desserts(String name, double price, int
public void display() { quantity) {
System.out.println(quantity + "x " + name + " - " + this.name = name;
computeTotal());
this.price = price;
}
this.quantity = quantity;
public double computeTotal() {
}
return price * quantity;
public void display() {
}
System.out.println(quantity + "x " + name + " - " +
public int getQuantity() { computeTotal());
return quantity; }
} public double computeTotal() {
} return price * quantity;
}
package main; public int getQuantity() {
public class Foods { return quantity;
private String name; }
private double price; }
private int quantity;
public Foods(String name, double price, int quantity)
{
this.name = name;
this.price = price;
this.quantity = quantity;
}
public void display() {
System.out.println(quantity + "x " + name + " - " +
computeTotal());
}
public double computeTotal() {
return price * quantity;
}
public int getQuantity() {
return quantity;
}
}
private static Drinks getDrinkChoice(Scanner scanner) { return scanner.nextInt(); 6

System.out.println("\n--- Drinks Menu ---"); } catch (InputMismatchException e) {


System.out.println("1. Iced Tea - 50.00"); System.out.println("Invalid input. Please
System.out.println("2. Coffee - 70.00"); enter a number.");

System.out.println("0. Receipt"); scanner.next();

while (true) { }

System.out.print("Enter choice: "); }

int choice = getValidInteger(scanner); }

switch (choice) { private static int getQuantity(Scanner scanner,


String itemName) {
case 1: return new Drinks("Iced Tea", 50.0,
getQuantity(scanner, "Iced Tea")); while (true) {
case 2: return new Drinks("Coffee", 70.0, System.out.print("Enter quantity for " +
getQuantity(scanner, "Coffee")); itemName + ": ");
case 0: return null; int quantity = getValidInteger(scanner);
default: System.out.println("Invalid choice. if (quantity > 0) return quantity;
Please try again.");
System.out.println("Invalid quantity. Please
} enter a positive number.");
} }
} }
private static Desserts getDessertChoice(Scanner
private static double getValidPayment(Scanner
scanner) {
scanner, double totalCost) {
System.out.println("\n--- Desserts Menu ---");
while (true) {
System.out.println("1. Sundae - 100.00");
System.out.print("\nEnter payment amount: ");
System.out.println("2. Peach Mango Pie - 80.00");
try {
System.out.println("3. Coke Float - 90.00");
double payment = scanner.nextDouble();
System.out.println("0. Receipt");
if (payment >= totalCost) return payment;
while (true) {
System.out.println("Insufficient amount.
System.out.print("Enter choice: "); Please enter again.");
int choice = getValidInteger(scanner); } catch (InputMismatchException e) {
switch (choice) { System.out.println("Invalid input. Please
case 1: return new Desserts("Sundae", 100.0, enter a valid amount.");
getQuantity(scanner, "Sundae"));
scanner.next();
case 2: return new Desserts("Peach Mango Pie",
}
80.0, getQuantity(scanner, "Peach Mango Pie"));
}
case 3: return new Desserts("Coke Float", 90.0,
getQuantity(scanner, "Coke Float")); }
case 0: return null; }
default: System.out.println("Invalid choice.
Please try again.");
package main;
}
public class Drinks {
}
private String name;
}
private double price;
private static int getValidInteger(Scanner scanner) {
private int quantity;
while (true) {

try {
6
package main; case 0:

import java.util.InputMismatchException; if (totalCost > 0) {

import java.util.Scanner; System.out.println("\n Order Summary ");

public class Main { if (food != null) food.display();

public static void main(String[] args) { if (drink != null) drink.display();

Scanner scanner = new Scanner(System.in); if (dessert != null) dessert.display();

System.out.println("--- Welcome to the Restaurant System.out.println("\nTotal Items: " +


---"); totalItems);

double totalCost = 0; System.out.println("Total Price: " + totalCost);

int totalItems = 0; double payment = getValidPayment(scanner,


totalCost);
Foods food = null;
double change = payment - totalCost;
Drinks drink = null;
System.out.println("Payment successful!
Desserts dessert = null;
Change: " + change);
while (true) {
} else {
System.out.println("\nWhat would you like to
System.out.println("No items ordered. Thank
order?");
you for visiting!");
System.out.println("1. Food");
}
System.out.println("2. Drinks");
scanner.close();
System.out.println("3. Desserts");
return;
System.out.println("0. Receipt");
default:
System.out.print("Enter your choice: ");
System.out.println("Invalid choice. Please try
int choice = getValidInteger(scanner); again.");

switch (choice) { }

case 1: }

food = getFoodChoice(scanner);

if (food != null) { private static Foods getFoodChoice(Scanner scanner) {

totalCost += food.computeTotal(); System.out.println("\n--- Food Menu ---");

totalItems += food.getQuantity(); System.out.println("1. Burger - 120.00");

} System.out.println("2. Pizza - 150.00");

break; System.out.println("3. Pasta - 130.00");

case 2: System.out.println("0. Receipt");

drink = getDrinkChoice(scanner); while (true) {

if (drink != null) { System.out.print("Enter choice: ");

totalCost += drink.computeTotal(); int choice = getValidInteger(scanner);

totalItems += drink.getQuantity(); switch (choice) {

} case 1: return new Foods("Burger", 120.0,


getQuantity(scanner, "Burger"));
break;
case 2: return new Foods("Pizza", 150.0,
case 3: getQuantity(scanner, "Pizza"));
dessert = getDessertChoice(scanner); case 3: return new Foods("Pasta", 130.0,
if (dessert != null) { getQuantity(scanner, "Pasta"));

totalCost += dessert.computeTotal(); case 0: return null;

totalItems += dessert.getQuantity(); default: System.out.println("Invalid choice. Please try


again.");
}
}
break;
}
int choice = user.nextInt(); private int cardNumber; 5

if (choice < 1075376987 || choice > private int accountNumber;


1075376991) {
private int amount;
System.out.println("Invalid input\n");
private String uusername;
continue;
private String password;
}
private String email;
switch (choice) {
acc(String userName, String birthDate, int
case 1: cardNumber, int accountNumber, String uusername,
String password, String email, int amount) {
System.out.print("\nEnter amount to
withdraw: Php "); this.userName = userName;

int withdrawAmount = user.nextInt(); this.birthDate = birthDate;

if (withdrawAmount > this.cardNumber = cardNumber;


selectedAccount.getAmount()) {
this.accountNumber = accountNumber;
System.out.println("Insufficient
this.uusername = uusername;
balance.");
this.password = password;
continue;
this.email = email;
} else {
this.amount = amount;
selectedAccount.withdraw(withdrawAmount);
}
System.out.println("Withdrawal
successful. Updated balance: Php " + int setAmount() {
selectedAccount.getAmount());
return amount;
}
}
break;
int getAmount() {
case 2:
return amount;
System.out.print("\nEnter amount to
}
deposit: Php ");
void withdraw(int amount) {
int depositAmount = user.nextInt();
this.amount -= amount;
selectedAccount.deposit(depositAmount);
}
System.out.println("Deposit successful.
Updated balance: Php " + void deposit(int amount) {
selectedAccount.getAmount());
this.amount += amount;
break;
}
case 3:
public String toString() {
System.out.println("\nYour current
balance is: Php " + selectedAccount.getAmount()); return "Name: " + userName + "\n" +

break; "Birth Date: " + birthDate + "\n" +

case 4: "Card Number: " + cardNumber + "\n" +

System.out.println("\nThank you for "Account Number: " + accountNumber + "\n" +


banking with BDO San Mateo. Have a great day!"); "User Name: " + uusername + "\n" +
return; "Password: " + password + "\n" +
default:
"Email: " + email + "\n" +
System.out.println("\nInvalid choice.
Please try again."); "Amount: Php" + amount + "\n";
}
}
}
}
}

}
4 } else { package main; 5

System.out.println("\nBill per hour: " + import java.util.Scanner;


rate + " PHP");
public class Main {
System.out.println("No discount
public static void main(String[] args) {
applied.");
Scanner user = new Scanner(System.in);
System.out.println("Total Billing Cost: "
+ totalCost + " PHP");
} System.out.println("~~~~Welcome to BDO San
Mateo~~~");
}
System.out.println("Branch Number: 1234579");
void AgeGroup() {
System.out.println("Branch Address: Ampid Uno,
if (age >= 0 && age <= 1) {
San Mateo, Rizal");
System.out.println("Age Group:
System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Baby/Infant");
~~");
} else if (age >= 4 && age <= 6) {
System.out.println("\n97629 Kathryn Bernardo\
System.out.println("Age Group: n74927 Enn Botardo\n73619 Yunna Labbao");
Toddler");
System.out.print("Enter the Account Number: ");
} else if (age >= 7 && age <= 9) {
int accnum = user.nextInt();
System.out.println("Age Group:
acc selectedAccount = null;
Preschooler");
if (accnum == 97629) {
} else if (age >= 12 && age <= 14) {
selectedAccount = new acc("\nKathryn
System.out.println("Age Group: Primary
Bernardo", "May 14, 2005", 3976, 97629, "Kathryn",
School Boy");
"12345", "[email protected]", 1000);
} else if (age >= 18 && age <= 25) {
} else if (accnum == 74927) {
System.out.println("Age Group:
selectedAccount = new acc("\nEnn Botardo",
Adolescent/Teenager");
"July 30, 2007", 4782, 74927, "Enn", "38626",
} else if (age >= 30 && age <= 35) { "[email protected]", 5000);

System.out.println("Age Group: Adult"); } else if (accnum == 73619) {

} else if (age >= 40 && age <= 55) { selectedAccount = new acc("\nYunna Labbao",
"July 9, 2007", 8652, 73619, "Yunna", "07526",
System.out.println("Age Group: Middle
"[email protected]", 1200);
adulthood");
} else {
} else if (age >= 60 && age <= 70) {
System.out.println("No fund user with this
System.out.println("Age Group: Old
account number.");
Person");
return;
} else {
}
System.out.println("Age Group:
Unidentified"); System.out.println("\nAccount Details:");

} System.out.println(selectedAccount);

} while (true) {
System.out.println("\nSelect a Transaction:");

String getName() { System.out.println("1. Withdraw");

return name; System.out.println("2. Deposit");

} System.out.println("3. Check Balance");

} System.out.println("4. Close/Exit");
System.out.print("Enter your choice: ");
4
System.out.print("\nWould you want to select another System.out.println("Diagnosis: " + diagnosis);
patient? (yes/no): ");
System.out.println("Type of Room: " + roomType);
van.nextLine();
System.out.println("Number of Hours: " + hours);
String again = van.nextLine().toLowerCase();
}
if (!again.equals("yes")) {
System.out.println("Thank you!");
void Category() {
break;
if (hours >= 1 && hours <= 2) {
}
System.out.println("Category 1: Self-care (1 to 2
} hours per day)");
} else if (hours >= 3 && hours <= 4) {
van.close(); System.out.println("Category 2: Minimal care (3
to 4 hours)");
}
} else if (hours >= 5 && hours <= 6) {
}
System.out.println("Category 3: Intermediate
care (5 to 6 hours)");
package main;
} else if (hours >= 7 && hours <= 8 {
System.out.println("Category 4: Modified
import java.util.Scanner; intensive care (7 to 8 hours)");
} else if (hours <= 10) {

public class Hospital { System.out.println("Category 5: Intensive care


(up to 10 hours)");
String name, address, contactPerson, diagnosis,
roomType; }

int age, hours; }

Hospital(String name, int age, String address, String void billingWithDiscount() {


contactPerson, String diagnosis, String roomType, int
Scanner scanner = new Scanner(System.in);
hours) {
System.out.print("Is the patient a PWD or Senior
this.name = name;
Citizen? (yes/no): ");
this.age = age;
String isDiscounted =
this.address = address; scanner.nextLine().toLowerCase();

this.contactPerson = contactPerson;
this.diagnosis = diagnosis; int rate = roomType.equalsIgnoreCase("Private") ?
1000 : 400;
this.roomType = roomType;
int totalCost = rate * hours;
this.hours = hours;
}
if (isDiscounted.equals("yes")) {
double discount = totalCost * 0.20;
void displayDetails() {
double discountedCost = totalCost - discount;
System.out.println("\nDetails about the Patient:");
System.out.println("\nBill per hour: " + rate + "
System.out.println("Name: " + name);
PHP");
System.out.println("Age: " + age);
System.out.println("Discount: " + discount + "
System.out.println("Address: " + address); PHP");

System.out.println("Contact Person: " + System.out.println("Total Billing Cost after


contactPerson); Discount: " + discountedCost + " PHP");
3 4
package main; package main;

public class MOVIE { import java.util.Scanner;

String TITLE,director; public class Main {

String ratings,genre,character; public static void main(String[] args) {

String year,SPG; Scanner van = new Scanner(System.in);

Employeee(String TITLE,String director,String


ratings,String genre,String character ) {
System.out.println("~~Welcome to Hospital
this.TITLE = TITLE; Record~~~");

this.director = director; System.out.println("\n PATIENT LIST: ");

this.ratings = ratings;

this.genre = genre; Hospital patient1 = new Hospital("Bornales, Harvey",


18, "Toneo", "0929572948283", "Kidney disease",
this.character = character;
"Private", 14);
year = "N/A";
Hospital patient2 = new Hospital("Parido, Rowena", 6,
SPG="N/A"; "Antipolo", "027288289178", "Heart failure", "Private", 3);

} Hospital patient3 = new Hospital("Paglinawan, Maica",


80, "Parañaque", "0983383838688", "Fever", "Private", 5);
Employeee( String TITLE, String director, String
ratings,String genre) Hospital patient4 = new Hospital("Marcos, Requillas",
29, "Rizal", "094878489999", "Cancer", "Ward", 1);
{
Hospital patient5 = new Hospital("Rudinas, Neckol",
this.TITLE = TITLE;
15, "Visayas", "0947372282888", "Dengue", "Ward", 8);
this.director = director;
Hospital[] patients = {patient1, patient2, patient3,
this.ratings = ratings; patient4, patient5};

this.genre = genre;

character = "N/A"; while (true) {

year = "N/A"; for (int i = 0; i < patients.length; i++) {

SPG="N/A"; System.out.println((i + 1075376987) + ". " +


patients[i].getName());
}
}
Employeee (String TITLE,

String director,
System.out.print("\nChoose a patient use the
String ratings, (Patient Code): ");
String genre, int choice = van.nextInt();
String character,

String year, if (choice < 1075376987 || choice > 1075376991) {


String SPG) System.out.println("Invalid input\n");
{ continue;
this.TITLE = TITLE; }
this.director = director;

this.ratings = ratings; Hospital patient = patients[choice - 1075376987];


this.genre = genre; patient.displayDetails();
this.character = character; patient.Category();
this.year = year; patient.AgeGroup();
this.SPG=SPG; patient.billingWithDiscount();
}

}
3
package main; case 5:
import java.util.Scanner; Employeee e5 = new Employeee("\nFruit
Basket", "Yoshihide Ibata", "5/5", "Animation", "Tohru,
public class Main {
Yuki, Kyo, Akito\n");
public static void main(String[] args) {
displayMovieDetails(e5);
Scanner scanner = new Scanner(System.in);
break;
while (true) {
case 6:
System.out.println("\nTICKET FOR Movie");
Employeee e6 = new Employeee("\nThe
System.out.println("SELECT Movie:"); Kingdom", "Michael Tuviera", "5/5", "Drama\n");
System.out.println("1. Coco"); displayMovieDetails(e6);
System.out.println("2. Jumanji"); break;
System.out.println("3. Hunter x Hunter"); default:
System.out.println("4. Black Clover"); System.out.println("Invalid choice.");
System.out.println("5. Fruit Basket"); }
System.out.println("6. The Kingdom"); System.out.print("\nDo you want to choose
another movie? (yes or no): ");
System.out.print("\nEnter the Movie number (1-
6): "); scanner.nextLine();
int movieNumber = scanner.nextInt(); String choice = scanner.nextLine();
switch (movieNumber) { if (choice.equalsIgnoreCase("No")) {
case 1: System.out.println();
Employeee e1 = new Employeee("\nCoco", System.out.println(" Thank you for
"Lee Unkrich", "5/5", "Action", "mama coco, ernesto, reviewing. \n Exiting...");
tia rosita", "2017", "PG\n");
Break;
displayMovieDetails(e1);
} else if (choice.equalsIgnoreCase("Yes")) {
break;
System.out.println("\n Select another movie.\
case 2: n");
Employeee e2 = new Employeee("\ } else{
nJumanji", "Jake Kasdan", "5/5", "Adventure", "Dr.
System.out.println("\n Invalid! pls Repeat.");
Smolder, Ruby, Bethany, Spencer", "2017", "PG\n");
}
displayMovieDetails(e2);
}
break;
}
case 3:
private static void displayMovieDetails(Employeee
Employeee e3 = new Employeee("\nHunter
movie) {
x Hunter", "Hiroshi Kōjina", "5/5", "Suspense", "Killua,
Gon, Hisoka, Kurapika", "2011", "SPG\n"); System.out.println("\nTitle: " + movie.TITLE);
displayMovieDetails(e3); System.out.println("Director: " + movie.director);
break; System.out.println("Ratings: " + movie.ratings);
case 4: System.out.println("Genre: " + movie.genre);
Employeee e4 = new Employeee("\nBlack System.out.println("Characters: " +
Clover", "Tatsuya Yoshihara", "5/5", "Fantasy", "Asta, movie.character);
Noelle, Yami, Julius", "2020", "SPG\n");
System.out.println("Year: " + movie.year);
displayMovieDetails(e4);
System.out.println("SPG: " + movie.SPG);
break;
}
}
2
import java.util.Scanner; int finalPrice = price;
public class Main { if (vipChoice.equals("yes")) {
public static void main(String[] args) { finalPrice += 200;
Scanner scanner = new Scanner(System.in); }

String[] MovieNames = { System.out.print("\nHow many tickets do you


want to buy? ");
"BTS", "BINI", "BLACKPINK", "SB19", "Sarah G"
int quantity = scanner.nextInt();
};
int[] prices = {400, 450, 500, 600, 550};
System.out.println("\nYour Selected Concert");
String[] times = {
System.out.println(MovieName + " \nEntrance fee:
"6:00 PM", "7:30 PM", "8:00 PM", "9:00 PM",
" + finalPrice + " \nTime: " + time + " \nDate: " + date +
"7:00 PM"
"\n");
};
String[] dates = {
int totalPrice = finalPrice * quantity;
"2025-01-15", "2025-01-16", "2025-01-17",
System.out.println("\nTotal Price: " + totalPrice);
"2025-01-18", "2025-01-19"
};
System.out.println("Thank you for your
purchase!");
System.out.println("\nAvailable Movie!!");
}
for (int i = 0; i < MovieNames.length; i++) {
}
System.out.println((i + 1) + ". " +
package main;
MovieNames[i]);
class UIFruits {
}
String concertName;
int price;
System.out.print("\nEnter the number of the
concert you want: "); String time;
int choice = scanner.nextInt(); String date;

if (choice < 1 || choice > MovieNames.length) { UIFruits(String concertName, int price, String time,
String date) {
System.out.println("Invalid choice.");
this.concertName = concertName;
return;
this.price = price;
}
this.time = time;
String MovieName = MovieNames[choice - 1];
this.date = date;
int price = prices[choice - 1];
}
String time = times[choice - 1];
void displayDetails() {
String date = dates[choice - 1];
System.out.println("Movie: " + concertName);
}
System.out.print("\nIf you want VIP? (yes or no): ");
}
String vipChoice = scanner.next().toLowerCase();

You might also like