Untitled

 avatar
unknown
plain_text
2 years ago
1.7 kB
7
Indexable
public static void main(String args[]) {
        String[] shape = { "Circle", "Square", "Oval", "Rectangle" };
        var selected = JOptionPane.showOptionDialog(null, "Enter the shape of your pizza", "Pizza Slices Calculator", 
                                                          0, 3, null, options, options[0]);
        if (selected == 0) {
            string input = JOptionPane.showInputDialog("Enter the radius of circular pizza");
            double radius = Double.parseDouble(input)
            circle(radius)
        }
        if (selected == 1) { 
            string input = JOptionPane.showInputDialog("Enter the side of a squared pizza");
            double side = Double.parseDouble(input)
            slices = square(side)
            JOptionPane.showMessageDialog(null, "The max number of slices is: " + slices);
        }
        if (selected == 2) { 
            string input1 = JOptionPane.showInputDialog("Enter the major axis of oval pizza");
            double majorAxis = Double.parseDouble(input)
            string input2 = JOptionPane.showInputDialog("Enter the minor axis of oval pizza");
            double minorAxis = Double.parseDouble(input)
            oval(majorAxis, minorAxis)
        }
        if (selected == 3) {
            string input1 = JOptionPane.showInputDialog("Enter the length of rectangular pizza");
            double length = Double.parseDouble(input1)
            string input2 = JOptionPane.showInputDialog("Enter the width of rectangular pizza");
            double width = Double.parseDouble(input2)
            slices = rectangle(length, width)
            JOptionPane.showMessageDialog(null, "The max number of slices is: " + slices);
            
        }
    }
Editor is loading...