Menu

[solved]-Trying User Input Reprinted Part Next Dialog Box Display Error Message M Getting Shoppingc Q39010308

I am trying to have the user input reprinted as part of the nextdialog box display.

This is the error message I’m getting.

(shoppingCart.java:11: error: incompatible types: String cannotbe converted to int
int dialogButton= JOptionPane.showConfirmDialog ( null,”Welcome “+userName,+” Are you ready to shop?” ); )

This is my code

import java.util.ArrayList;
import javax.swing.JOptionPane;
public class shoppingCart {
private ArrayListListOfItems;
private String userName;
public void shopperName(){
userName=JOptionPane.showInputDialog(null, “Hello valued customer,please enter your name to continue.”);
  
int dialogButton= JOptionPane.showConfirmDialog ( null,”Welcome “,userName,”. Are you ready to shop?” );
if(dialogButton==JOptionPane.YES_OPTION){
JOptionPane.showMessageDialog(null, “Okay, Let’s shop”);
}
  
if(dialogButton== JOptionPane.NO_OPTION ){
JOptionPane.showMessageDialog(null, “Have a great day.”);
System.exit(0);

Never mind I figured it out. The code is correct

Expert Answer


Answer to I am trying to have the user input reprinted as part of the next dialog box display. This is the error message I’m getti… . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *