adding_drill
                This is an old revision of the document!
Adding Drill
- Make a new class calledQuestion
- Make two integer fields calledaandb
- Make a constructor that initializes a and b so they have a random number from one to ten
- Make a method calledcorrectthat has aintparameter returns true if the parameter is the correct sum a+b
- Make an overloaded method calledcorrectthat has aStringparameter returns true if the parameter is the correct sum a+b. UseInteger.parseInt()to convert theStringto anint
- Make a method calledtoStringthat returns the question “What is a + b?”
- Make a main method that creates a instance toScanner, andQuestion. Useimport java.util.Scanner;before the class declaration
- Try asking one question and checking if it is correct.
- Try using awhileloop that keeps asking the question until the question is answered correctly.
- Try using aforloop so you ask 3 different questions. Here is how it might look:
adding_drill.1601394997.txt.gz · Last modified: 2020/09/29 11:56 by frchris
                
                 
 