You will create a program that helps the user make a difficu


You will create a program that helps the user make a difficult decision. You can either choose either: a gift to give based on the month of the year or help them decide a place to eat based on the night of the week. Explain to the user what your program does. Asks the user either which night or which month (you may ask either for a word or a number or given them options to select from) Ask the user how many choices they would like (you may restrict this such as: would you like 1, 2, or 3 suggestion?) You must include 5-10 options for each night or month. For example Monday might have the options: McDonalds, Hardness, Burger king, Wendy\'s, Taco Johns or the month of January might have options: a parka, gloves, boots, a scarf, a ski pass, ice skates, or a toboggan. You must use each of the following at least one time in your program: repetition statement(s) switch/case statement(s) array(s) *User Interface (UI) must incorporate J libraries

Solution

hope this will help

import javax.swing.* and java.awt.* etc..
import javax.swing.JOptionPane;

public class MakingDecisions {


    public static void main(String[] args) {

          String[] choices = {\"Monday\", \"Tuesday\",\"Wednesday\", \"Thursday\", \"Friday\", \"Saturday\", \"Sunday\"};

        String dayPicked = (String)JOptionPane.showInputDialog(null, \"Pick a day:\", \"Days of the Week\", JOptionPane.QUESTION_MESSAGE, null, choices, choices[0]);

        if (dayPicked == null)
        {
            JOptionPane.showMessageDialog(null, \"You didn\'t pick a day!\");
        }
        else //executes when a dayPicked has been a value.
        {
            //Note: For this switch to work it must be used with JDK7 (or higher)
            //The string picked is used as a conparison against the case statements. When a match is found the code in that case block will be executed. If none of the         //cases match the default case statement is triggered.
            String funfact = \"\";
            switch (dayPicked)
            {
                case \"Monday\":
                    funfact = \"McDonald\";
                    break;
                case \"Tuesday\":
                    funfact = \"Burger King\";
                    break;
                case \"Wednesday\":
                    funfact = \"wendy\'s.\";
                    break;
                case \"Thursday\":
                    funfact = \"Taco Johns\";
                    break;
                case \"Friday\":
                    funfact = \"KFC\";
                    break;
                case \"Saturday\":
                    funfact = \"Hardees\";
                    break;
                case \"Sunday\":
                    funfact = \"Sub-way\";
                    break;
                default:
                    funfact = \"Something went wrong with picking a day of the \"
                            + \"week as I\'m a default fact \"
                            + \"that is no fun at all!\";
                    break;
            }
            JOptionPane.showMessageDialog(null, funfact);
        }

        //Options for Numbers between 1 and 12 input dialog

        Integer[] oneToTen = {1,2,3,4,5,6,7,8,9,10,11,12};

        //Input dialog box allowing the user to pick a day of the week.
        Integer numberPicked = (Integer)JOptionPane.showInputDialog(null, \"Pick a Number:\"
                , \"Numbers between 1 and 12\", JOptionPane.QUESTION_MESSAGE
                , null, oneToTen, oneToTen[0]);

        //Use an if then else statement to see if the user picks a number.If picked has a null value it means the input dialog box was closed
        //either by pressing cancel or by using the close \'x\' button.
        if (numberPicked == null)
        {
            JOptionPane.showMessageDialog(null, \"You didn\'t pick a number!\");
        }
        else //executes because numberPicked has a value.
        {
            //turn the Integer object into a simple int value.
            int choice = numberPicked.intValue();

            String xmasSong = \"\";
            String day = \"\";
            //The int chosen is used as a conparison against the case statements. When a match is found the code in that case block will
            //be executed. If none of the cases match the default case statement is triggered.
            switch (choice)
            {
                case 1:
                    day = \"first\";
                    xmasSong = \"A partridge in a pear tree.\";
                    break;
                case 2:
                    day = \"second\";
                    xmasSong = \"2 Turtle Doves\";
                    break;
                case 3:
                    day = \"third\";
                    xmasSong = \"3 French Hens\";
                    break;
                case 4:
                    day = \"fourth\";
                    xmasSong = \"4 Calling birds\";
                    break;
                case 5:
                    day = \"fifth\";
                    xmasSong = \"5 Gold Rings\";
                    break;
                case 6:
                    day = \"sixth\";
                    xmasSong = \"6 Geese-a-laying\";
                    break;
                case 7:
                    day = \"seventh\";
                    xmasSong = \"7 Swans-a-Swimming\";
                    break;
                case 8:
                    day = \"eigth\";
                    xmasSong = \"8 Maids-a-Milking\";
                    break;
                case 9:
                    day = \"nineth\";
                    xmasSong = \"9 Ladies Dancing\";
                    break;
                case 10:
                    day = \"tenth\";
                    xmasSong = \"10 Lords-a-Leaping\";
                    break;
                case 11:
                    day = \"eleventh\";
                    xmasSong = \"11 Pipers Piping\";
                    break;
                case 12:
                    day = \"twelveth\";
                    xmasSong = \"12 Drummers Drumming\";
                    break;
                default:
                    day = \"special day\";
                    xmasSong = \"ferrari\";
                    break;
            }
            JOptionPane.showMessageDialog(null, \"On the \" + day + \"day of \" + \"Christmas.\ \" + xmasSong);
        }
    }
}

 You will create a program that helps the user make a difficult decision. You can either choose either: a gift to give based on the month of the year or help th
 You will create a program that helps the user make a difficult decision. You can either choose either: a gift to give based on the month of the year or help th
 You will create a program that helps the user make a difficult decision. You can either choose either: a gift to give based on the month of the year or help th

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site