[Solved]Java Create Java Class Example Output Would Food Select 1 Burger 2 Pizza 1 User Inputs Num Q37051641
java
create java class
the example of output would be this:
food select 1. burger 2. pizza
1 // the user inputs number here
what is the name of the burger and how many do you want?
chicken 3 // the user inputs any name and number here
burger: chicken
3
so I have to create 3 classes
interface foodie{
}
abstract class Food implements foodie{
string name;
int number;
}
class burger extends Food{
}
class pizza extends Food{
}
// and here is my main method
class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int foodSelect, number;
String name;
foodie food;
System.out.println(“food select 1.burger 2. pizza”);
whatToEat = sc.nextInt();
if (foodSelect == 1) {
System.out.println(“what is thename of the burger and how many do you want?
“);
name =sc.next();
number =sc.nextInt();
food = newburger(name, number);
}
else if (foodSelect == 2) {
System.out.println(“what is thename of the pizza and how many do you want?
“);
name = sc.next();
number = sc.nextInt();
food = new pizza(name,number);
}
else {
sc.close();
return;
}
food.select();
food.number();
sc.close();
}
}
Expert Answer
Answer to java create java class the example of output would be this: food select 1. burger 2. pizza 1 // the user inputs number h… . . .
OR

