Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

java coding :- Don\'t use java Swing . Using Java Fx and OOPS concepts ,Style th

ID: 3918401 • Letter: J

Question

java coding :-

Don't use java Swing .

Using Java Fx and OOPS concepts ,Style the 3 scenes in this app using separate stylesheets. For a application called PizzaShop (have all choices for regular and feast pizza)

Scenes will be :

In the first scene, ask name, type (radiobutton) and size of pizza (radiobutton) and let the user add toppings (CheckBox, check for max toppings for each of the pizza type ) Show a logo on top left corner with all the title for your shop.

Once the user clicks a button in scene1, it takes him to scene 2 where the user sees his order details and a choice to choose his payment.(use radiobutton here). Once the user clicks a payment button in scene 2, it takes him to scene 3.

3. In scene 3, For debit and credit payment show a hyperlink window which takes the user to the respective payment sites, ex interac for debit., paypal for credit. and an image of cash for cash option.

Explanation / Answer

SOLUTION:

The below represents the code and it is as shown below;

import java.text.DecimalFormat;

import java.util.Scanner;

public class pizzaorder{

public static void main(String[] args){

DecimalFormat df = new DecimalFormat("#.####");

Scanner keyboard = new Scanner(System.in);

String Cust_Name;

char Pizza_Type;

String Pizza_Type_Name;

char Payment_Method;

string payment_Method_Name;

int size;

double price = 0.0;

final double Tax_perc = 5;

double tax;

double total_Pizza;

double GrandTotal;

int numberOfToppings1 = 0;

int numberOfToppings2 =0;

int numberOfToppings3;

String toppings = "Pepperoni";

System.out.println("Enter your name: " );

Cust_Name = keyboard.nextLine();

System.out.print("What size of pizza would you like (diameter in inches)? (8, 10, 12, 14, or 16) " );

size = keyboard.nextInt();

if (size == 8 ){

price = 9.0000; }

else if (size == 10){

price = 10.0000;}

else if (size == 12){

price = 12.0000;}

else if (size == 14){

price = 14.0000;}

else if (size == 16){

price = 16.0000;}

else if (size != 8 && size != 10 && size != 12 && size != 14 && size != 16){

System.out.println("The value that you have entered is invalid. You will be offered default pizza size of 8 inches " );

price = 9;}

keyboard.nextLine();

System.out.print("What type of pizza do you want? (RH)Regular-hand tossed, (RT)Regular -Thin-crust, or (F)Feast (enter RH, RT, or F,): " );

Pizza_Type = keyboard.nextLine().charAt(0);

if (Pizza_Type == 'RH' || Pizza_Type == 'rh' ){

Pizza_Type_Name = "Regular & Hand-Tossed";}

else if (Pizza_Type == 'RT' || Pizza_Type == 'rt' ){

Pizza_Type_Name = "Regular &Thin-Crust";}

else if (Pizza_Type == 'F' || Pizza_Type == 'f' ){

Pizza_Type_Name = "Feast & Deep-Dish";}

else if (Pizza_Type != 'RH' && Pizza_Type != 'rh' && Pizza_Type != 'RT' && Pizza_Type    != 'rt' && Pizza_Type != 'F' && Pizza_Type != 'f' ){

System.out.println("The pizza type you have entered is invalid. You will be offered Regular – Hand tossed pizza . " );}

Pizza_Type_Name = "Regular & Hand-Tossed";

System.out.println("Our Pizzas have Pepperoni as default topping." );

System.out.println("If you want additional toppings you can , choose from Mushroom (2$) or Sausage(2$)." );

System.out.println("Do you want Mushroom? (Y/N)" );

numberOfToppings 1= keyboard.nextLine().charAt(0);

if (numberOfToppings1 == 'Y' || numberOfToppings1 == 'y' ){

numberOfToppings1 = 1;

toppings = toppings + " and Mushroom";}

else{

numberOfToppings1 = 0;

}

System.out.println("Do you want Sausage? (Y/N)" );

numberOfToppings2 = keyboard.nextLine().charAt(0);

if (numberOfToppings2 == 'Y' || numberOfToppings2 == 'y' ){

numberOfToppings2 = 1;

toppings = toppings + " and Sausage";}

else{

numberOfToppings2 = 0;}

numberOfToppings3 = (numberOfToppings1) + (numberOfToppings2);

total_Pizza= (price) + (numberOfToppings3 * 2) ;

tax = total_Pizza * (Tax_perc/100);

GrandTotal = total_Pizza * ( 1 + (Tax_perc/100) );

System.out.println(firstName + ", here are the details of your order:");

System.out.println(size + " inch pizza");

System.out.println(Pizza_Type_Name + ", " + toppings);

System.out.println("Order price: $" + df.format(total_Pizza));

System.out.println("Tax: $" + df.format(Tax_perc));

System.out.println("Total Due: $" + df.format(GrandTotal));

    }

   }

keyboard.nextLine();

System.out.print("How would you like to pay for your pizza? (C)Credit Card, (D)Debit card, or (CH)Cash (enter C, D, or CH,): " );

Payment _Method= keyboard.nextLine().charAt(0);

if (Payment_Method == 'C' || Payment_Method == 'c' ){

Payment_Method_Name = "Credit Card";

Clicklink();

}

else if (Payment_Method == 'D' || Payment_Method == 'd' ){

Payment_Method_Name = "Debit Card";

Clicklink();

}

else if (Payment_Method == 'CH' || Payment_Method == 'ch' ){

Payment_Method_Name = "Cash";}

else if (Payment_Method != 'C' && Payment_Method != 'c' && Payment_Method != 'D' && Payment_Method    != 'd' && Payment_Method != 'CH' && Payment_Method != 'ch' ){

System.out.println("The payment method you have selected is invalid.You payment method will be set to cash " );}

Payment_Method_Name = "Cash";

keyboard.nextLine();

}

}

public void ClickLink(ActionEvent event) throws Exception {              

        try {

        FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("payment_page/fxml"));

                Parent root1 = (Parent) fxmlLoader.load();

                Stage stage = new Stage();

                stage.setScene(new Scene(root1));

                stage.show();

        } catch(Exception e) {

           e.printStackTrace();

          }

}

Therefore by using the above code we can get our required output