# sequence of integers

• February 28th, 2012, 11:31 PM
einjhelclint12
sequence of integers
I'm new in java so i really don't now what to do in this problem..my teacher wants me do a program for this problem ...anyone help me with this.

A sequence of integers is an "integer chain with rings of r" if the difference between each consecutive number is at most r.
Write a program that tests if a sequence of integers is an integer chain.
The program prompts the user to enter the number of integers (between 2 and 20) and the desired ring width 'r'.
It will output whether the sequence is a chain or where the chain is broken

Sample run 1:
Enter sequence length and ring width: 6 3
Enter 6 integers: 7 10 8 9 12 12
This is an integer chain of length 6 with rings of 3
• February 28th, 2012, 11:34 PM
copeg
Re: sequence of integers
Please read the forum rules. Double posting is one of them, and is not allowed. Your other post has been removed.
• February 29th, 2012, 06:59 AM
Norm
Re: sequence of integers
Be sure to wrap your code with[code=java]<YOUR CODE HERE>[/code] to get highlighting
• March 1st, 2012, 06:49 PM
einjhelclint12
Re: sequence of integers
[code =java]
package integersequence;
import java.io.IOException;

public class IntegerSequence {

public static void main(String[] args) {

String length = "";
System.out.println("Enter the Length:");
try{

} catch (IOException e){
System.out.print("Error");

}
System.out.println("The Length is:"+ length);

String ring = "";
System.out.println("Enter the Ring Width:");
try{

} catch (IOException e){
System.out.print("Error");

}
System.out.println("The Ring Width is:"+ ring);

String sint = "";
System.out.println("Enter the integers:");
try{

} catch (IOException e){
System.out.print("Error");

}
System.out.println("The Value of Integers are:"+ sint);
int x;
x= Integer.parseInt(length);

int[] anArray;
anArray = new int[x];

}
}
[/code]