I need a code that when I'm given two number, the computeer gives me back 4 integers

ex) user gives me: "3 & 6"
The computer displays back: "3,4,5,6"

So the numbers have to be in a continuous sequence? Or is that just a coincidence in the bad example you picked? Because from what you stated, you could just generate four random integers and display them and you're done. Or do two of the numbers have to be the ones the user entered? If so, what do the other numbers have to be... anything, like you said, or some sort of sequence, like your example implied?

Also. . . do your own work. We don't do code for you. Explain your problem better, then attempt to code it on your own. If you have any problems you can ask specific questions that don't say "do this for me", but that say "I need some guidance", and we will answer those. Also, post your code, in code tags.

Thanks for your advice.... & sorry I didn't post the code
Im new at java & I wanted to know if there was another way to get the same results.

Example problem:

user inputs any 2 numbers (3 & 6)
computer displays (3, 4, 5, 6)

This is what I have: :)

import java.util.*;


class Excercise10{
public static void main(String[] args){
Scanner keyboard = new Scanner(System.in);


int num1;
int num2;
int count1;
int count2;
int count3;
int count4;


System.out.println("please enter 2 numbers");
num1 = keyboard.nextInt();
num2 = keyboard.nextInt();


count1 = (num1);
count2 = (count1 + 1);
count3 = (count2 + 1);
count4 = (num2);


System.out.println("your four numbers are "+count1+", "+count2+", "+count3+", "+count4);
}
}

So the numbers have to be in a continuous sequence? Or is that just a coincidence in the bad example you picked? Because from what you stated, you could just generate four random integers and display them and you're done. Or do two of the numbers have to be the ones the user entered? If so, what do the other numbers have to be... anything, like you said, or some sort of sequence, like your example implied?
Also. . . do your own work. We don't do code for you. Explain your problem better, then attempt to code it on your own. If you have any problems you can ask specific questions that don't say "do this for me", but that say "I need some guidance", and we will answer those. Also, post your code, in code tags.

the way you are doing it makes it so that your code doesnt work when the user enters numbers that are more than two numbers apart. I suggest an array to store the numbers in between the two user entered numbers, that way your code is more robust, which is a very important part of programming.

Yes, you could do this more easily. As an example,

System.out.println("Here's an example for you. " + num + ", " + (num + 1) + "");

Where I have (num + 1) in parenthesis that lets the compiler know that you're adding with the + sign. Otherwise, the compiler would think you're doing String concatenation. (If you take out the parenthesis there, it will print out 01 because it combined the two Strings).

Also, your problem is confusing to begin with. Like I said, and like the person above me just mentioned, do the numbers have to be in a series? For example what do you want your output to be if the person types in 1 and 5? 1, 2, 3, 5?

Thank you

the way you are doing it makes it so that your code doesnt work when the user enters numbers that are more than two numbers apart. I suggest an array to store the numbers in between the two user entered numbers, that way your code is more robust, which is a very important part of programming.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.