For my homework, I was asked to write a simple math test program with two levels of difficulty: easy and hard.
The problem is, when I run the program and choose a difficulty level, it acts as if I spelled the difficulty wrong. It would probably be best if someone could run this program to see what exactly happens. I've been trying to figure out what I'm doing wrong for hours now; everything seems to basic and easy, I can't imagine what I'm doing wrong.
The problem is your test for the level entered by the user. == does not test that the words are the same, it tests that the object references are the same ie they reference the same object. When testing that 2 objects are equal in value to each other you should always use the equals() method. Although in this case it might be better to use the equalsIgnoreCase() method which is a special equals test provided by the String class to allow an equals test to be done regardless of the capitalisation of the strings.
Joined: Sep 22, 2007
Thank you very much!
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com