Create a programme

Write an interactive program that accomplishes each of the following tasks:
(a) This program will ask the user to choose an option out of 4 options listed below when the program starts. This is the menu:
 Option 1 to ask me how I am feeling today
 Option 2 to ask me who I am
 Option 3 to make me count from 1 to 9 and then 11 to 15
 Option 4 to convert a number to name of the month
 Option 5 to terminate the program

(b) When Option 1 is selected, the following statement will be randomly generated.
1. I feel fine
2. I've been better
3. I feel horrible
4. I feel terrific

(c) When Option 2 is selected, the computer name is display on the message box.
Example:
I am Sam, the computer

(d) When Option 3 is selected, the program should print out number from 1 to 9 and then 11 to 15 is display on the message box.
Example:
123456789
1112131415

(e) When Option 4 is selected, an input message box will appear to prompt user to enter an integer value representing a month from the user. The purpose is to output the name of the month in the dialog box. E.g. when the user input 2, the program will output February. However, if the user input an integer less than 1 or more than 12, a message must show that it is an invalid input in the dialog box.

(f) When Option 5 is selected, the program should exit.

Hint: Your program should use either switch-case or if-else statements to help to determine the user option. Use JOptionPane to obtain the option from user and displaying the results. The marks for component 2 and 3 will be awarded when the students used user-defined method(s) to accomplish this program.
Name the java file as AssignmentQuestion1.java

Test Data
For question 1 and 2, students must provide at least 5 sets of different output. Here are the instructions:

Comments

  • : Write an interactive program that accomplishes each of the following tasks:
    : (a) This program will ask the user to choose an option out of 4 options listed below when the program starts. This is the menu:
    :  Option 1 to ask me how I am feeling today
    :  Option 2 to ask me who I am
    :  Option 3 to make me count from 1 to 9 and then 11 to 15
    :  Option 4 to convert a number to name of the month
    :  Option 5 to terminate the program
    :
    : (b) When Option 1 is selected, the following statement will be randomly generated.
    : 1. I feel fine
    : 2. I've been better
    : 3. I feel horrible
    : 4. I feel terrific
    :
    : (c) When Option 2 is selected, the computer name is display on the message box.
    : Example:
    : I am Sam, the computer
    :
    : (d) When Option 3 is selected, the program should print out number from 1 to 9 and then 11 to 15 is display on the message box.
    : Example:
    : 123456789
    : 1112131415
    :
    : (e) When Option 4 is selected, an input message box will appear to prompt user to enter an integer value representing a month from the user. The purpose is to output the name of the month in the dialog box. E.g. when the user input 2, the program will output February. However, if the user input an integer less than 1 or more than 12, a message must show that it is an invalid input in the dialog box.
    :
    : (f) When Option 5 is selected, the program should exit.
    :
    : Hint: Your program should use either switch-case or if-else statements to help to determine the user option. Use JOptionPane to obtain the option from user and displaying the results. The marks for component 2 and 3 will be awarded when the students used user-defined method(s) to accomplish this program.
    : Name the java file as AssignmentQuestion1.java
    :
    : Test Data
    : For question 1 and 2, students must provide at least 5 sets of different output. Here are the instructions:
    :
    :
    Here's a nice start:
    [code]
    public class MyProgram extends JFrame {

    public static void main(String[] args) {
    MyProgram frame = MyProgram();
    MyProgram.setSize(640, 480);
    MyProgram.setVisible(true);
    }

    }
    [/code]
    Good luck with the questions.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion