Question: JAVA What's wrong with my code??? I am getting the same prompts (illegal start...and identifier expected) in 4 main method calls Here is what I
JAVA What's wrong with my code??? I am getting the same prompts (illegal start...and identifier expected) in 4 main method calls
Here is what I have so far (I included the error messages on the line where it applies):
import java.util.*;
public interface Incrementable{
public void increment(); public void getValue(); } public class SequentialIncrementer implements Incrementable{ int value = 0; public void increment(){ value = value+1; } public void getValue() { return value; } }
public class RandomIncrementer implements Incrementable{ int value; public void increment(){ this.value = (int)(Math.random()*100); value = value + (int)(Math.random()*100); } public int getValue(){ return value; } } public class Tester{ public static void main (String []args); SequentialIncrementer sequence = new SequentialIncrementer(); RandomIncrementer random = new RandomIncrementer();
System.out.println /* error:
System.out.println /*34: error:
Here is the problem I wish to solve:
Declare an interface called 'Incrementable' that stores integers to be incremented in some way; create a method called 'increment' that increments; create a method called 'getValue' that returns the value; write 2 classes called SequentialIncrementer and RandomIncrementer that implements the interface; The SequentialIncrementer begins with its value at 0 and increases it by one each time; the RandomIncrementer begings its value at a random integer and changes it to a new random integer at each increment.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
