lundi 24 avril 2017

Java IF statement issues [duplicate]

This question already has an answer here:

Hi i am having trouble with my If statement. A user is suppose to input a and number 2 will be printed out. if they input anything else a message dialog is suppose to pop up. would really appreciate some help. thank you

import java.awt.Component;
import java.util.Scanner;
import javax.swing.JOptionPane;

public class size {
    public static void main(String[] args) {
        Scanner pizzasize = new Scanner(System.in);
        Double hello;
        double a = 2;
        hello = pizzasize.nextDouble();
        if( hello != a){
            Component panel = null;
            JOptionPane.showMessageDialog(panel, "Could not open file", "Error", JOptionPane.ERROR_MESSAGE);
        } else {
            Object input = null;
            if(input.equals("a")) {
                System.out.println (a);
            }
        }
    }
}

Aucun commentaire:

Enregistrer un commentaire