Convert the following C++ Code into Java Object-Oriented Programming: #include…
- User
Convert the following C++ Code into Java Object-Oriented Programming:
#include using namespace std; int main() { int menu, bill, quantity, soda, burger, chicken, pasta;
std:: cout << " Please select your order. \n"; cout << " Main Menu \n"; std:: cout << " Soda press 1 \n Burger press 2 \n Chicken press 3 \n Pasta press 4 \n\n"; cout << " Enter code from main menu:"; std:: cin >> menu;
if ((menu <=0) || (menu >=5)) { std:: cout<< "Invalid code! Please check the menu again."; }
else if (menu == 1) { std:: cout << " Please select : Soda \n"; std:: cout << " Coke: P25 press 1 \n Pepsi: P28 press 2 \n RC: P26 press 3 \n\n"; std:: cout << " Enter code from soda menu: "; std:: cin >> soda;{ if ((soda <=0) || (soda >=4)) { std:: cout<< "Invalid code! Please check the menu again."; } else { std:: cout <<"\n Please enter number of order: "; std:: cin >> quantity; } } if (soda == 1) { bill = quantity25; std:: cout << " Your bill is " << bill; std:: cout << "\n Please pay at the counter. Thank you & come again!"; } else if (soda == 2) { bill = quantity28; std:: cout << " Your bill is " << bill; std:: cout << "\n Please pay at the counter. Thank you & come again!"; } else if (soda == 3) { bill = quantity*26; std:: cout << " Your bill is " << bill; std:: cout << "\n Please pay at the counter. Thank you & come again!"; }
} else if (menu == 2) { std:: cout << " Please select : Burger \n"; std:: cout << " Regular Burger: P25 press 1 \n Cheese Burger: P35 press 2 \n Ham & egg Burger: P50 press 3 \n\n"; std:: cout << " Enter code from Burger menu: "; std:: cin >> burger;{ if ((burger <=0) || (burger >=4)) { std:: cout<< "Invalid code! Please check the menu again."; } else { std:: cout <<"\n Please enter number of order: "; std:: cin >> quantity; } } if (burger == 1) { bill = quantity25; std:: cout << " Your bill is " << bill; std:: cout << "\n Please pay at the counter. Thank you & come again!"; } else if (burger == 2) { bill = quantity35; std:: cout << " Your bill is " << bill; std:: cout << "\n Please pay at the counter. Thank you & come again!"; } else if (burger == 3) { bill = quantity50; std:: cout << " Your bill is " << bill; std:: cout << "\n Please pay at the counter. Thank you & come again!"; } } else if (menu == 3) { std:: cout << " Please select : Chicken \n"; std:: cout << " Crispy fried chicken: P60 press 1 \n Chicken BBQ: P75 press 2 \n Buttered Chicken: P85 press 3 \n\n"; std:: cout << " Enter code from Chicken menu: "; std:: cin >> chicken; { if ((chicken <=0) || (chicken >=4)) { std:: cout<< "Invalid code! Please check the menu again."; } else { std:: cout <<"\n Please enter number of order: "; std:: cin >> quantity; } } if (chicken == 1) { bill = quantity60; std:: cout << " Your bill is " << bill; std:: cout << "\n Please pay at the counter. Thank you & come again!"; } else if (chicken == 2) { bill = quantity75; std:: cout << " Your bill is " << bill; std:: cout << "\n Please pay at the counter. Thank you & come again!"; } else if (chicken == 3) { bill = quantity85; std:: cout << " Your bill is " << bill; std:: cout << "\n Please pay at the counter. Thank you & come again!"; } } else if (menu == 4) { std:: cout << " Please select : Pasta \n"; std:: cout << " Italian Pasta: P120 press 1 \n Cream cheese Pasta: P160 press 2 \n Pesto Pasta: P175 press 3 \n\n"; std:: cout << " Enter code from Pasta menu: "; std:: cin >> pasta;{ if ((pasta <=0) || (pasta >=4)) { std:: cout<< "Invalid code! Please check the menu again."; } else { std:: cout <<"\n Please enter number of order: "; std:: cin >> quantity; } } if (pasta == 1) { bill = quantity160; std:: cout << " Your bill is " << bill; std:: cout << "\n Please pay at the counter. Thank you & come again!"; } else if (pasta == 3) { bill = quantity*175; std:: cout << " Your bill is " << bill; std:: cout << "\n Please pay at the counter. Thank you & come again!"; } } return 0; }
- Assistant
- User
- Assistant
import java.util.Scanner;
public class Main { public static void main(String[] args) { int menu, bill, quantity, soda, burger, chicken, pasta;
System.out.println("Please select your order."); System.out.println("Main Menu"); System.out.println("