// A sample food project for Internal Assessment import java.util.*; public class Resturant_Management { public static void main(String args[]) { Scanner in = new Scanner(System.in); int vstr,tvstr=0,nvstr,tnvstr=0,vfd,tvfd=0,nvfd, tnvfd=0,fd,tfd=0,amt=0,tamt=0,tamt1=0,tamt2=0,totald=0,damt=0,ch; double gst=0,tot,gtotal; String str="",choice,choice1="Y"; System.out.println("Welcome to the Multi Cuisine Restaurant!!!"); System.out.println("Starter Corner: 1"); System.out.println("Main Course: 2"); System.out.println("Desserts: 3"); System.out.println(); while(choice1.equalsIgnoreCase("Y")) { System.out.println("Enter for Starter "); System.out.println("Enter for Main Course :"); System.out.println("Enter for Desserts"); System.out.println(); System.out.println("Enter Your Choice "); ch=in.nextInt(); switch(ch) { case 1: System.out.println("Welcome to Starter Menu!!!:"); System.out.println("Enter 'VS' for Veg Starter and 'NVS' for Non-Veg Starter"); str=in.next(); if(str.equalsIgnoreCase("VS")) { System.out.println("Starters\t\t\tPrice in Rs."); System.out.println("1.Paneer Tikka\t\t\t\t110"); System.out.println("2. Veg Seekh Kabab\t\t\t110"); System.out.println("3.Hara Bhara Kabab\t\t\t110"); System.out.println("4.Shanghai Spring Roll\t\t\t150"); System.out.println("5.American Corn Ball\t\t\t150"); System.out.println("6.Crispy American Corn\t\t\t140"); System.out.println("7.Crispy Baby Corn\t\t\t140"); System.out.println("8.Crispy Mushroom\t\t\t120"); System.out.println("9.Crispy Chilly Potato\t\t\t120"); System.out.println("10.Crispy Chilly Chana\t\t\t150"); System.out.println(); choice="Y"; while(choice.equalsIgnoreCase("Y")) { System.out.println("Choose the veg starter by entering number:"); vstr =in.nextInt(); System.out.println("Enter the quantity:"); tvstr=in.nextInt(); if(vstr>=1 && vstr <=3) amt= tvstr *110; if(vstr ==4|| vstr ==5||vstr==10) amt= tvstr *150; if(vstr ==6||vstr ==7 ) amt= tvstr *140; if(vstr ==8|| vstr ==9) amt= tvstr *120; tamt=tamt+amt; System.out.println("Do you want to place more order? Enter Y/N"); choice=in.next(); } } if(str.equalsIgnoreCase("NVS")) { System.out.println("Non-Veg Starters\t\t\tPrice in Rs."); System.out.println("1.Chicken Tikka\t\t\t\t170"); System.out.println("2.Murg Reshmi Kabab\t\t\t170"); System.out.println("3.Murg Chilli Kabab\t\t\t160"); System.out.println("4.Chicken Seekh Kabab\t\t\t180"); System.out.println("5.Tangdi Kabab\t\t\t\t180"); System.out.println("6.Murg Tandoori\t\t\t\t190"); System.out.println("7.Fish Ajwani Tikka\t\t\t190"); System.out.println("8.Chilli Chicken\t\t\t160"); System.out.println("9.Drums of Heaven\t\t\t180"); System.out.println("10.Shanghai Chiken\t\t\t180"); choice="Y"; while(choice.equalsIgnoreCase("Y")) { System.out.println("Choose the non-veg starter by entering number:"); nvstr= in.nextInt(); System.out.println("Enter the quantity:"); tnvstr=in.nextInt(); if(nvstr==1||nvstr==2) amt =tnvstr* 170; if(nvstr==3||nvstr==8) amt =tnvstr*160; if(nvstr==4||nvstr=-5||nvstr==9||nvstr==10) amt =tnvstr* 180; if(nvstr==6||nvstr==7) amt =tnvstr* 190; tamt=tamt+amt; System.out.println("Do you want to place more order? Enter Y/N"); choice=in.next(); } } break; case 2: System.out.println("Main Course: Indian and Chinese Dishes!"); System.out.println("Enter V for Indian Veg Dishes, NV for Indian Non-Veg Dishes and'C' for Chinese Dishes"); str=in.next(); System.out.println(str.equalsIgnoreCase("V")); if(str.equalsIgnoreCase("V")) { System.out.println("Welcome to Indian Veg Dishes"); System.out.println("Indian Veg Dishes\t\t\t\t Price in Rs."); System.out.println("1.Shahi Paneer\t\t\t\t\t\t180"); System.out.println("2.Navratan Korma\t\t\t\t\t 180"); System.out.println("3.Kadahi Paneer\t\t\t\t\t\t150"); System.out.println("4.Malai Kofta\t\t\t\t\t\t140"); System.out.println("5.Kadahi Vegetable\t\t\t\t\t 140"); System.out.println("6. Vegetable Pakeeza\t\t\t\t\t140"); System.out.println("7.Shabnam Curry\t\t\t\t\t\t150"); System.out.println("8.Makai Corn Palak\t\t\t\t\t150"); System.out.println("9.Veg. Pulao\t\t\t\t\t\t110"); System.out.println("10.Kashmiri Pulao\t\t\t\t\t140"); System.out.println("11.Butter Naan\t\t\t\t\t\t40"); System.out.println("12.Stuffed Kulcha \t\t\t\t\t60"); choice="Y"; while(choice.equalsIgnoreCase("Y")) { System.out.println("Choose the order by entering number: "); vfd=in.nextInt(); System.out.println("Enter the quantity"); tvfd=in.nextInt(); if(vfd==1||vfd==2) amt =tvfd* 180; if(vfd==3||vfd==7|lvfd==8) amt =tvfd*150; if(vfd==4||vfd==5||vfd==6||vfd==10) amt=tvfd*140; if(vfd==9) amt=tvfd*110; if(vfd=11) amt=tvfd*40; if(vfd==12) amt=tvfd*60; tamtl=tamtl+amt; System.out.println("Do you want to place more order? Enter Y/N"); choice=in.next(); } } if(str.equalsIgnoreCase("NV")) System.out.println("Welcome to Indian Non-Veg Dishes"); System.out.println("Indian Non-Veg Dishes\t\t\t\t Price in Rs."); System.out.println("1.Chicken Tikka Masala\t\t\t\t\t180"); System.out.println("2.Chicken Tikka Labadar\t\t\t\t\t180"); System.out.println("3.Chicken Bharta\t\t\t\t\t 150"); System.out.println("4.Kadahi Chicken\t\t\t\t\t 160"); System.out.println("5.Mughlai Chicken\t\t\t\t\t160"); System.out.println("6.Murg Navratan Korma\t\t\t\t\t 160"); System.out.println("7.Chicken Do Pyaza\t\t\t\t\t170"); System.out.println("8.Murg Masallam\t\t\t\t\t\t 170"); System.out.println("9.Mutton Rogan Josh\t\t\t\t\t 190"); System.out.println("10.Prawn Malai Curry\t\t\t\t\t 190"); System.out.println("11.Fish Sarsowala\t\t\t\t\t140"); System.out.println("12.Fish Dhaniawala \t\t\t\t\t 160"); choice="Y"; while(choice.equalsIgnoreCase("Y")) { System.out.println("Choose the order by entering number: "); vfd=in.nextInt(); System.out.println("Enter the quantity"); tvfd=in.nextInt(); if(vfd==1||vfd==2) amt =tvfd*180; if(vfd==3) amt =tvfd* 150; if(vfd==4||vfd==5||vfd==6||vfd==12) amt =tvfd* 160; if(vfd =7||vfd==8) amt=tvfd*170; if(vfd =9|lvfd =10) amt=tvfd* 190; if(vfd==11) amt =tvfd* 140; tamt1= tamt1+amt; System.out.println("Do you want to place more order? Enter Y/N"); choice=in.next(); } } if(str.equalsIgnoreCase("C")) { System.out.println("Welcome to Chinese Dishes"); System.out.println("Chinese Dishes\t\t\t\t Price in Rs."); System.out.println("1.Schezwan Fried Rice\t\t\t\t240"); System.out.println("2.Schezwan Chicken\t\t\t\t280"); System.out.println("3.Chilly Chicken\t\t\t\t280"); System.out.println("4.Chicken Noodle\t\t\t\t210"); System.out.println("5.Veg. Hakka Noodle\t\t\t\t210"); System.out.println("6.Chicken Manchurian\t\t\t\t 190"); System.out.println("7.Paneer Manchurian\t\t\t\t190"); System.out.println("8.Chilly Paneer\t\t\t\t\t 190"); System.out.println("9.Sanghai Fried Rice\t\t\t\t240"); System.out.println("10.Veg. Fried rice\t\t\t\t210"); System.out.println("11.Chicken Fried Rice\t\t\t\t210"); System.out.println("12.Kimchi Rice Veg.\t\t\t\t210"); choice="Y"; while(choice.equalsIgnoreCase("Y")) { System.out.println("Choose the order by entering number: "); fd=in.nextInt(); System.out.println("Enter the quantity"); tfd=in.nextInt(); if(fd==1||fd==9) amt=tfd*240; if(fd==2||fd==3) amt=tfd*280; if(fd==4||fd==5||fd==10||fd==11||fd==12) amt=tfd*210; if(fd==6||fd==7||fd==8) amt=tfd*190; tamtl=tamtl+amt; System.out.println("Do you want to place more order? Enter Y/N"); choice=in.next(); } } break; case 3: System.out.println("Deserts\t\t\t\t\t Price in Rs."); System.out.println(); System.out.println("1.Softy Pineapple\t\t\t\t 110"); System.out.println("2.Softy Crunchy Chocolate\t\t\t110"); System.out.println("3.Chocolate Walnut Brownie\t\t\t90"); System.out.println("4.Chocolate Doughnut\t\t\t\t90"); System.out.println("5.Marble Cake\t\t\t\t\t70"); System.out.println("6.Mocha Magic\t\t\t\t\t90"); System.out.println("7.Black Forest \t\t\t\t90"); System.out.println("8.Mango Shake\t\t\t\t\t80"); System.out.println("9.Pineapple Shake\t\t\t\t80"); System.out.println("10.Tooty Fruity\t\t\t\t\t120"); choice="Y"; while(choice.equalsIgnoreCase("Y")) { System.out.println("Choose your desert by entering your number!!"); d=in.nextInt(); System.out.println("Enter the total number of items you want to buy!!"); totald=in.nextInt(); if(d==1||d==2) damt =totald*110; if(d==3||d==4||d==6||d==7) damt=totald*90; if(d==5) damt=totald*70; if(d==8||d==9) damt=totald*80; if(d==10) damt=totald*120; tamt2=tamt2+damt; System.out.println("Do you want to place more order? Enter Y/N"); choice=in.next(); } break; default: System.out.println("You have entered wrong choice!!."); } System.out.println("Enter 'Y' to go to Main Menu!!"); choice1= in.next(); } System.out.println("*******Multi Cuisine Restaurant ********"); System.out.println("**********Starter*************"); System.out.println("Total cost of starter= Rs."+tamt); System.out.println("**********Main Course*************"); System.out.println("Total cost of main course= Rs."+tamt1); System.out.println("**********Desserts*************"); System.out.println("Total cost of desserts Rs."+tamt2); tot =tamt+tamt1+tamt2; gst=tot* 18.0/100.0; System.out.println("GST =Rs. "+gst); gtotal=tot+gst; System.out.println("Amount to be paid Rs. "+gtotal); System.out.println("Thanks for visiting Multi Cuisine Restaurant!!"); System.out.println("Your Pleasure Our Comfort!!!"); System.out.println("Visit Again!!!"); System.out.println("Program Ends!!"); } }
Write, Run & Share Java code online using OneCompiler's Java online compiler for free. It's one of the robust, feature-rich online compilers for Java language, running the Java LTS version 17. Getting started with the OneCompiler's Java editor is easy and fast. The editor shows sample boilerplate code when you choose language as Java and start coding.
OneCompiler's Java online editor supports stdin and users can give inputs to the programs using the STDIN textbox under the I/O tab. Using Scanner class in Java program, you can read the inputs. Following is a sample program that shows reading STDIN ( A string in this case ).
import java.util.Scanner;
class Input {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.println("Enter your name: ");
String inp = input.next();
System.out.println("Hello, " + inp);
}
}
OneCompiler supports Gradle for dependency management. Users can add dependencies in the build.gradle
file and use them in their programs. When you add the dependencies for the first time, the first run might be a little slow as we download the dependencies, but the subsequent runs will be faster. Following sample Gradle configuration shows how to add dependencies
apply plugin:'application'
mainClassName = 'HelloWorld'
run { standardInput = System.in }
sourceSets { main { java { srcDir './' } } }
repositories {
jcenter()
}
dependencies {
// add dependencies here as below
implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.9'
}
Java is a very popular general-purpose programming language, it is class-based and object-oriented. Java was developed by James Gosling at Sun Microsystems ( later acquired by Oracle) the initial release of Java was in 1995. Java 17 is the latest long-term supported version (LTS). As of today, Java is the world's number one server programming language with a 12 million developer community, 5 million students studying worldwide and it's #1 choice for the cloud development.
short x = 999; // -32768 to 32767
int x = 99999; // -2147483648 to 2147483647
long x = 99999999999L; // -9223372036854775808 to 9223372036854775807
float x = 1.2;
double x = 99.99d;
byte x = 99; // -128 to 127
char x = 'A';
boolean x = true;
When ever you want to perform a set of operations based on a condition If-Else is used.
if(conditional-expression) {
// code
} else {
// code
}
Example:
int i = 10;
if(i % 2 == 0) {
System.out.println("i is even number");
} else {
System.out.println("i is odd number");
}
Switch is an alternative to If-Else-If ladder and to select one among many blocks of code.
switch(<conditional-expression>) {
case value1:
// code
break; // optional
case value2:
// code
break; // optional
...
default:
//code to be executed when all the above cases are not matched;
}
For loop is used to iterate a set of statements based on a condition. Usually for loop is preferred when number of iterations is known in advance.
for(Initialization; Condition; Increment/decrement){
//code
}
While is also used to iterate a set of statements based on a condition. Usually while is preferred when number of iterations are not known in advance.
while(<condition>){
// code
}
Do-while is also used to iterate a set of statements based on a condition. It is mostly used when you need to execute the statements atleast once.
do {
// code
} while (<condition>);
Class is the blueprint of an object, which is also referred as user-defined data type with variables and functions. Object is a basic unit in OOP, and is an instance of the class.
class
keyword is required to create a class.
class Mobile {
public: // access specifier which specifies that accessibility of class members
string name; // string variable (attribute)
int price; // int variable (attribute)
};
Mobile m1 = new Mobile();
public class Greeting {
static void hello() {
System.out.println("Hello.. Happy learning!");
}
public static void main(String[] args) {
hello();
}
}
Collection is a group of objects which can be represented as a single unit. Collections are introduced to bring a unified common interface to all the objects.
Collection Framework was introduced since JDK 1.2 which is used to represent and manage Collections and it contains:
This framework also defines map interfaces and several classes in addition to Collections.
Collection | Description |
---|---|
Set | Set is a collection of elements which can not contain duplicate values. Set is implemented in HashSets, LinkedHashSets, TreeSet etc |
List | List is a ordered collection of elements which can have duplicates. Lists are classified into ArrayList, LinkedList, Vectors |
Queue | FIFO approach, while instantiating Queue interface you can either choose LinkedList or PriorityQueue. |
Deque | Deque(Double Ended Queue) is used to add or remove elements from both the ends of the Queue(both head and tail) |
Map | Map contains key-values pairs which don't have any duplicates. Map is implemented in HashMap, TreeMap etc. |