Decoding Java: Crafting Your Food Ordering App's Blueprint (Part 1)


In this blog, we will look at how to create a simple menu of food items and its price.
As it is part 1 of the application we have kept the program simple. In every coming part, we will add more functionality and make our program or app more dynamic and relevant to the real world.
Here is the Code of our first Program:
import java.util.*; // Import the java.util package, which includes the Scanner class for user input
public class FoodOrderL1 {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in); // Create a Scanner object to capture user input
System.out.println("Here is the Menu");
System.out.println("Enter 1 for Pizza of ₹99\nEnter 2 for Burger of ₹69\nEnter 3 for Chowmien of ₹49\nEnter 4 for Pasta of ₹79");
int choice = sc.nextInt(); // Capture user's choice as an integer
switch (choice) { // Use a switch statement to process the user's choice
case 1:
System.out.println("You Ordered Pizza at ₹99");
break; // Exit the switch after processing this case
case 2:
System.out.println("You Ordered Burger at ₹69");
break; // Exit the switch after processing this case
case 3:
System.out.println("You Ordered Chowmein at ₹49");
break; // Exit the switch after processing this case
case 4:
System.out.println("You Ordered Pasta at ₹79");
break; // Exit the switch after processing this case
default:
System.out.println("You entered an Invalid number"); // Executes if user input doesn't match any case
}
}
}
Your Task:
Create your Food order app with the same functionality but with your favorite food items.
Add at least 5 food items to the menu.
(Bonus) Also, input the username from the user and print " --name-- thanks for ordering"
(Mandatory) Tag Me #JavaFoodOrderW_A_V Ayush Vanvary
Subscribe to my newsletter
Read articles from Ayush Vanvary directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Ayush Vanvary
Ayush Vanvary
Hello, I'm Ayush Vanvary. Skilled in Python Django and MySQL, I'm equally passionate about sharing my expertise as a tech educator. With experience as a Java tutor, I've honed both my coding prowess and teaching abilities. Additionally, I regularly contribute insights through straightforward, informative tech blogs, enriching readers and nurturing a vibrant community