import java.util.Scanner;
public class HotelManagement1 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println(" \t\t\tWelcome To Our Hotel Management ");
//to display menu
System.out.println(" \t\t*******");
int order_id;
System.out.println("Enter the number of orders");
int n = sc.nextInt();
Order[] order = new Order[n];
for (int i = 0; i < n; i++) {
order[i] = new Order();
}
int ch = 0;
do {
System.out.println(" 1. Placing Order");
System.out.println(" 2. Cancelling Order ");
System.out.println(" 3. Updating Order");
System.out.println(" 4. Display Order ");
System.out.println(" 5. Display Individual Order");
System.out.println("6.Exit");
System.out.println("Enter your choice");
ch = sc.nextInt();
switch (ch) {
case 1:
System.out.println(" Placing order ");
int flag = 0;
for (int i = 0; i < n; i++) {
System.out.println("\t\t Enter order id");
order_id = sc.nextInt();
if (order_id != order[i].id) {//if (order_id == order[i].retorder_id()) {
System.out.println(" Order to be Added");
// order[i].display();
order[i].id = order_id;
order[i].read();
flag = 1;
}
}
if (flag == 0) {
System.out.println("Invalid Order_id");
}
break;
case 2:
System.out.println(" Cancelling Order ");
System.out.println("\t\t Enter Order_id");
order_id = sc.nextInt();
flag = 0;
for (int i = 0; i < n; i++) {
if (order_id == order[i].id) {
System.out.println(" Order to be Cancelled ");
order[i].display();
order[i].delete();
order[i].display();
flag = 1;
}
}
if (flag == 0) {
System.out.println("Invalid Order_id");
}
break;
case 3:
System.out.println(" Updating Order");
System.out.println("\t\t Enter order_id");
order_id = sc.nextInt();
flag = 0;
for (int i = 0; i < n; i++) {
if (order_id == order[i].id) {
System.out.println(" Order to be Updated");
order[i].display();
order[i].read();
flag = 1;
}
}
if (flag == 0) {
System.out.println(" Invalid Order_id");
}
break;
case 4:
for (int i = 0; i < n; i++) {
System.out.println(" Data of order_id " + order[i].id + "");
order[i].display();
}
break;
case 5:
//int Order_id;
System.out.println(" Enter Order_id to search:");
order_id = sc.nextInt();
flag = 0;
for (int i = 0; i < n; i++) {
if (order_id == order[i].id) {
order[i].display();
flag = 1;
}
}
if (flag == 0) {
System.out.println(" Invalid Order_id");
}
break;
case 6:
System.out.println("Thankyou For Order!");
}
} while (ch < 7);
}
}
//second class
class Order {//order info class
int id;//ORDER ID
String Customer_Name;
String Food_item;
int Orders;//Quantity of food item
double Price;
double Tip;
public void read()//taking order
{
Scanner sc = new Scanner(System.in);
System.out.println("Enter the Customer_Name");
Customer_Name = sc.next();
System.out.println("Enter the Food_item");
Food_item = sc.next();
System.out.println("Enter the Orders");
Orders = sc.nextInt();
System.out.println("Enter the Price");
Price = sc.nextDouble();
System.out.println("Enter the Tip");
Tip = sc.nextDouble();
}
public void display()//details of order
{
System.out.println("Customer_Name=" + Customer_Name);
System.out.println("Food_item=" + Food_item);
System.out.println("Orders=" + Orders);
System.out.println("Price=" + Price);
System.out.println("Tip=" + Tip);
}
public void delete()//delete order
{
Orders = 0;
Food_item = "nil";
Price = 0.0;
Tip = 0.0;
}
public void update() {
}
public void displayInd()//details of order
{
System.out.println("Customer_Name=" + Customer_Name);
System.out.println("Food_item=" + Food_item);
System.out.println("Orders=" + Orders);
System.out.println("Price=" + Price);
System.out.println("Tip=" + Tip);
}
int retorder_id() {
return Orders;
}
String retfood_item() {
return Food_item;
}
}
—-------------------------------------------Output —-------------------------------------------------------
run:
Welcome To Our Hotel Management
*******
Enter the number of orders
2
1. Placing Order
2. Cancelling Order
3. Updating Order
4. Display Order
5. Display Individual Order
6.Exit
Enter your choice
1
Placing order
Enter order id
101
Order to be Added
Enter the Customer_Name
Suresh
Enter the Food_item
Biryani
Enter the Orders
2
Enter the Price
100
Enter the Tip
50
Enter order id
102
Order to be Added
Enter the Customer_Name
Ramesh
Enter the Food_item
Icecream
Enter the Orders
3
Enter the Price
50
Enter the Tip
20
1. Placing Order
2. Cancelling Order
3. Updating Order
4. Display Order
5. Display Individual Order
6.Exit
Enter your choice
4
Data of order_id 101
Customer_Name=Suresh
Food_item=Biryani
Orders=2
Price=100.0
Tip=50.0
Data of order_id 102
Customer_Name=Ramesh
Food_item=Icecream
Orders=3
Price=50.0
Tip=20.0
1. Placing Order
2. Cancelling Order
3. Updating Order
4. Display Order
5. Display Individual Order
6.Exit
Enter your choice
5
Enter Order_id to search:
102
Customer_Name=Ramesh
Food_item=Icecream
Orders=3
Price=50.0
Tip=20.0
1. Placing Order
2. Cancelling Order
3. Updating Order
4. Display Order
5. Display Individual Order
6.Exit
Enter your choice
3
Updating Order
Enter order_id
102
Order to be Updated
Customer_Name=Ramesh
Food_item=Icecream
Orders=3
Price=50.0
Tip=20.0
Enter the Customer_Name
RameshUpdt
Enter the Food_item
NewFood
Enter the Orders
2
Enter the Price
150
Enter the Tip
20
1. Placing Order
2. Cancelling Order
3. Updating Order
4. Display Order
5. Display Individual Order
6.Exit
Enter your choice
4
Data of order_id 101
Customer_Name=Suresh
Food_item=Biryani
Orders=2
Price=100.0
Tip=50.0
Data of order_id 102
Customer_Name=RameshUpdt
Food_item=NewFood
Orders=2
Price=150.0
Tip=20.0
1. Placing Order
2. Cancelling Order
3. Updating Order
4. Display Order
5. Display Individual Order
6.Exit
Enter your choice
2
Cancelling Order
Enter Order_id
102
Order to be Cancelled
Customer_Name=RameshUpdt
Food_item=NewFood
Orders=2
Price=150.0
Tip=20.0
Customer_Name=RameshUpdt
Food_item=nil
Orders=0
Price=0.0
Tip=0.0
1. Placing Order
2. Cancelling Order
3. Updating Order
4. Display Order
5. Display Individual Order
6.Exit
Enter your choice
4
Data of order_id 101
Customer_Name=Suresh
Food_item=Biryani
Orders=2
Price=100.0
Tip=50.0
Data of order_id 102
Customer_Name=RameshUpdt
Food_item=nil
Orders=0
Price=0.0
Tip=0.0
1. Placing Order
2. Cancelling Order
3. Updating Order
4. Display Order
5. Display Individual Order
6.Exit
Enter your choice
Comments
Post a Comment