Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
import java.util.ArrayList;
import java.util.Scanner;

// Class to represent each Flight
class Flight {
String flightNo;
String airline;
String source;
String destination;
int seatsAvailable;
double price;

Flight(String flightNo, String airline, String source, String destination, int seatsAvailable, double price) {
this.flightNo = flightNo;
this.airline = airline;
this.source = source;
this.destination = destination;
this.seatsAvailable = seatsAvailable;
this.price = price;
}

public void displayInfo() {
System.out.printf("%-10s %-15s %-15s %-15s %-10d ₹%.2f%n",
flightNo, airline, source, destination, seatsAvailable, price);
}
}

// Class for Flight Management System
public class FlightManagementSystem {
private static ArrayList<Flight> flights = new ArrayList<>();
private static Scanner sc = new Scanner(System.in);

public static void main(String[] args) {
int choice;
do {
System.out.println("\n========= ✈️ Flight Management System =========");
System.out.println("1. Add Flight");
System.out.println("2. View All Flights");
System.out.println("3. Search Flight");
System.out.println("4. Book Ticket");
System.out.println("5. Cancel Ticket");
System.out.println("6. Exit");
System.out.print("Enter your choice: ");
choice = sc.nextInt();
sc.nextLine(); // consume newline

switch (choice) {
case 1 -> addFlight();
case 2 -> viewFlights();
case 3 -> searchFlight();
case 4 -> bookTicket();
case 5 -> cancelTicket();
case 6 -> System.out.println("👋 Exiting Flight Management System. Goodbye!");
default -> System.out.println("❌ Invalid choice! Please try again.");
}
} while (choice != 6);
}

// Add flight
public static void addFlight() {
System.out.print("Enter Flight Number: ");
String flightNo = sc.nextLine();

System.out.print("Enter Airline Name: ");
String airline = sc.nextLine();

System.out.print("Enter Source: ");
String source = sc.nextLine();

System.out.print("Enter Destination: ");
String destination = sc.nextLine();

System.out.print("Enter Available Seats: ");
int seats = sc.nextInt();

System.out.print("Enter Ticket Price: ₹");
double price = sc.nextDouble();
sc.nextLine();

flights.add(new Flight(flightNo, airline, source, destination, seats, price));
System.out.println("✅ Flight added successfully!");
}

// View all flights
public static void viewFlights() {
if (flights.isEmpty()) {
System.out.println("⚠️ No flights available.");
return;
}

System.out.println("\n---------------- Flight List ----------------");
System.out.printf("%-10s %-15s %-15s %-15s %-10s %s%n",
"FlightNo", "Airline", "Source", "Destination", "Seats", "Price");
System.out.println("---------------------------------------------------------------");
for (Flight f : flights) {
f.displayInfo();
}
}

// Search flight by number or destination
public static void searchFlight() {
System.out.print("Search by (1) Flight Number or (2) Destination: ");
int option = sc.nextInt();
sc.nextLine();

boolean found = false;
if (option == 1) {
System.out.print("Enter Flight Number: ");
String num = sc.nextLine();
for (Flight f : flights) {
if (f.flightNo.equalsIgnoreCase(num)) {
System.out.println("✅ Flight Found:");
f.displayInfo();
found = true;
}
}
} else if (option == 2) {
System.out.print("Enter Destination: ");
String dest = sc.nextLine();
System.out.println("Flights to " + dest + ":");
for (Flight f : flights) {
if (f.destination.equalsIgnoreCase(dest)) {
f.displayInfo();
found = true;
}
}
}

if (!found) System.out.println("❌ No matching flights found.");
}

// Book ticket
public static void bookTicket() {
System.out.print("Enter Flight Number to book: ");
String num = sc.nextLine();

for (Flight f : flights) {
if (f.flightNo.equalsIgnoreCase(num)) {
if (f.seatsAvailable > 0) {
f.seatsAvailable--;
System.out.println("🎟️ Ticket booked successfully for flight " + f.flightNo);
} else {
System.out.println("❌ No seats available on this flight.");
}
return;
}
}
System.out.println("❌ Flight not found.");
}

// Cancel ticket
public static void cancelTicket() {
System.out.print("Enter Flight Number to cancel ticket: ");
String num = sc.nextLine();

for (Flight f : flights) {
if (f.flightNo.equalsIgnoreCase(num)) {
f.seatsAvailable++;
System.out.println("🧾 Ticket cancelled successfully for flight " + f.flightNo);
return;
}
}
System.out.println("❌ Flight not found.");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Flight Management System

**Contributor:** lokhandeshreya165-prog

Flight Management System in Java (console-based) — easy to understand and perfect for projects or practice.
It allows you to add, view, search, book, and cancel flights using object-oriented programming concepts.
✈️ Features

✅ Add flight details
✅ View all flights
✅ Search flight by flight number or destination
✅ Book and cancel tickets
✅ Simple text-based interface (uses ArrayList for storage)
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
# Food Ordering System in Python
# Developed by ChatGPT (Console Based)

class FoodItem:
def __init__(self, id, name, price):
self.id = id
self.name = name
self.price = price

class FoodOrderingSystem:
def __init__(self):
self.menu = [
FoodItem(1, "Pizza", 250),
FoodItem(2, "Burger", 120),
FoodItem(3, "Pasta", 180),
FoodItem(4, "French Fries", 90),
FoodItem(5, "Cold Coffee", 80),
FoodItem(6, "Sandwich", 100)
]
self.cart = []

def display_menu(self):
print("\n======= 🍴 MENU =======")
print("{:<5} {:<15} {:<10}".format("ID", "Item", "Price (₹)"))
print("-----------------------------")
for item in self.menu:
print("{:<5} {:<15} {:<10}".format(item.id, item.name, item.price))
print("-----------------------------")

def add_to_cart(self):
self.display_menu()
try:
item_id = int(input("Enter item ID to order: "))
quantity = int(input("Enter quantity: "))

for item in self.menu:
if item.id == item_id:
self.cart.append({"item": item, "quantity": quantity})
print(f"✅ {item.name} x{quantity} added to cart.")
return
print("❌ Invalid item ID.")
except ValueError:
print("⚠️ Please enter a valid number.")

def view_cart(self):
if not self.cart:
print("🛒 Your cart is empty.")
return

print("\n======= 🧾 YOUR CART =======")
total = 0
print("{:<15} {:<10} {:<10}".format("Item", "Qty", "Price"))
print("--------------------------------")
for order in self.cart:
item = order["item"]
quantity = order["quantity"]
price = item.price * quantity
print("{:<15} {:<10} {:<10}".format(item.name, quantity, price))
total += price

gst = total * 0.05
grand_total = total + gst
print("--------------------------------")
print(f"Subtotal: ₹{total:.2f}")
print(f"GST (5%): ₹{gst:.2f}")
print(f"Total Bill: ₹{grand_total:.2f}")
print("--------------------------------")

def remove_item(self):
if not self.cart:
print("❌ Cart is empty.")
return

self.view_cart()
try:
item_name = input("Enter item name to remove: ").strip().lower()
for order in self.cart:
if order["item"].name.lower() == item_name:
self.cart.remove(order)
print(f"❎ {order['item'].name} removed from cart.")
return
print("❌ Item not found in cart.")
except Exception as e:
print("⚠️ Error:", e)

def checkout(self):
if not self.cart:
print("🛒 Your cart is empty.")
return

self.view_cart()
print("💳 Thank you for your order! Enjoy your meal 😋")
self.cart.clear()

def main_menu(self):
while True:
print("\n========== 🍔 FOOD ORDERING SYSTEM ==========")
print("1. View Menu")
print("2. Add to Cart")
print("3. View Cart")
print("4. Remove Item")
print("5. Checkout")
print("6. Exit")

choice = input("Enter your choice: ")

if choice == '1':
self.display_menu()
elif choice == '2':
self.add_to_cart()
elif choice == '3':
self.view_cart()
elif choice == '4':
self.remove_item()
elif choice == '5':
self.checkout()
elif choice == '6':
print("👋 Thank you! Visit again!")
break
else:
print("❌ Invalid choice. Please try again.")


# Run the system
if __name__ == "__main__":
system = FoodOrderingSystem()
system.main_menu()
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Food Ordering System
**Contributer:** lokhandeshreya165-prog

Food Ordering System in Python .
It’s simple, menu-driven, and great for understanding Python OOP, lists, and dictionaries.

🍽️ Features

✅ Display food menu
✅ Take customer orders
✅ Generate bill with GST
✅ Option to add/remove items
✅ Simple text-based interface
Loading