lundi 27 mars 2017

Combining boolean and if

I have just started my journey with Java. I would like to write a code which will ask user to make a choice between two lanugages: English and Spanish. User will type ENG and there should be "Hello my friend" printed or user will type ESP and there should be "Ola amigo" printed. If user will type something else there question will appear to make a correct choice again. Below is my code so far.. could you please help?

`

public class Main {
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);

        System.out.println("Make a language choice: ENG for ENGLISH or ESP for SPANISH");


        boolean ENG;  // determines English language
        boolean ESP;  //determines Spanish language

        if(ENG) {

            System.out.println("Hello my friend");
        }

        if(ESP) {
            System.out.println("Ola amigo");
        }

        else {
            System.out.println ("Make a language choice: ENGLISH or SPANISH");
        }

`

Aucun commentaire:

Enregistrer un commentaire