Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.

>> REGISTER NOW TO START POSTING

1. 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

2. 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.

3. Re: sequence of integers

Be sure to wrap your code with[code=java]<YOUR CODE HERE>[/code] to get highlighting

4. 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]