Question: Modify the program from Exercise E1.16 so that the dialog continues with the message My name is Hal! What would you like me to do?

Modify the program from Exercise E1.16 so that the dialog continues with the message “My name is Hal! What would you like me to do?” Discard the user’s input and display a message such as I'm sorry, Dave. I'm afraid I can't do that. Replace Dave with the name that was provided by the user.


Data from Exercise E1.16

Type in and run the following program. Then modify it to print “Hello, name!”,
displaying the name that the user typed in.


import javax.swing.JOptionPane;

public class DialogViewer
{
public static void main(String[] args)
{
String name = JOptionPane.showInputDialog("What is your name?");
System.out.println(name);
}
}

Step by Step Solution

3.40 Rating (162 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

ANSWER import javaxswingJOptionPane public class DialogViewer public static ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Java Concepts Late Objects Questions!