I'm hoping someone can help me with my homework assignment, or at least steer me in the right direction. I've got ZERO programming experience and am struggling bigtime, so I'm sorry if my questions seem dumb.
The assignment is: Create a simple Java program to generate a random number that is smaller than 100 and divide the number by 2. If the number is an odd number, display a message that this number is an odd number. Otherwise, display this number is an even number. Use the different types of method to develop this program:
public void displayResult(S tring)
public boolean isEvenNumber(in t)
public int getNextNumber()
public void execute()
public static void main()
This is what I have so far:
import java.util.*;
public class Homework06{
public static void main(String args[]){
Homework06 myHomework06 = new Homework06();
myHomework06.ge tRandom();
}
public void getRandom(){
Random randomNumbers = new Random();
int generateNum = randomNumbers.n extInt(100);
System.out.prin tln("\n\n\nThe number generated is " + generateNum);
if (generateNum % 2 == 0){
System.out.prin tln("The number generated is an even number");
}
else{
System.out.prin tln("The number generated is an odd number");
}
}
}
So at least I know this much works. But I have no idea what to do now. The lecture preceding this assignment was on method overload, if that makes sense. The books are not helping me at all. Any help or tips would save my sanity!! Thanks
The assignment is: Create a simple Java program to generate a random number that is smaller than 100 and divide the number by 2. If the number is an odd number, display a message that this number is an odd number. Otherwise, display this number is an even number. Use the different types of method to develop this program:
public void displayResult(S tring)
public boolean isEvenNumber(in t)
public int getNextNumber()
public void execute()
public static void main()
This is what I have so far:
import java.util.*;
public class Homework06{
public static void main(String args[]){
Homework06 myHomework06 = new Homework06();
myHomework06.ge tRandom();
}
public void getRandom(){
Random randomNumbers = new Random();
int generateNum = randomNumbers.n extInt(100);
System.out.prin tln("\n\n\nThe number generated is " + generateNum);
if (generateNum % 2 == 0){
System.out.prin tln("The number generated is an even number");
}
else{
System.out.prin tln("The number generated is an odd number");
}
}
}
So at least I know this much works. But I have no idea what to do now. The lecture preceding this assignment was on method overload, if that makes sense. The books are not helping me at all. Any help or tips would save my sanity!! Thanks
Comment