Hello":)
I have code and I wont your help in telling its right or wrong and what missing....

This is the question ::
If the user chooses 1, then the program asks the user: “Please enter a new dictionary file name”. The program creates a new file with this file name, then it asks the user: “Please enter a word and its meaning separated by a comma”. After the user enters the word and its meaning, the program asks the user “would you like to enter another word?” if the answer is yes, then the user is asked to enter another word. If the answer is no, the file is saved to disk and the user is presented with the original menu.

the code::

public class Dictionary {

    private static void Dictionary() {
        File file = new File("dictionary.txt");

        boolean success = false;
        try {
            // Create file on disk (if it doesn't exist)
            success = file.createNewFile();
        } catch (IOException e) {
        }

        if (success) {
            System.out.println("File did not exist and was created.\n");
        } else {
            System.out.println("File already exists.\n");
        }

    }

I have this Question also;;;;
The chooses when the user select 1,2,3 I do it in the main class yes or no??
Here in this "if the answer is yes, then the user is asked to enter another word.." it means using if statment yes or no??

Thank you....

Edited 3 Years Ago by Reverend Jim: Fixed formatting

I suggest you create a method to do the user interface - ie display the menu, get the input etc.
That will keep your code neat and organised = easy to read and undersand.
At this stage it's fine to put that in the main class.
"if the answer is yes..." Yes , you'll need some kind of if or similar statement here, but remember that the user input is a loop - you keep asking for more words over and over until the user says stop. As an alternative to an if you may prefer a do while or a do until loop.
Give it a try.

This article has been dead for over six months. Start a new discussion instead.