Hey guys i've been trying to write this program for ages please Help!!
how do i reverse an order of numbers starting with the input and working it's way down
Code Java:
import java.io.*;
import java.util.*;
public class question4
{
public static void main(String[] args)throws IOException
{
// Set up an input buffer for reading input values
BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
// Set up an output buffer for writing results to
PrintWriter output = new PrintWriter(System.out);
// Read in values
String line1 = input.readLine();
// Convert string into int
int x = Integer.parseInt(line1);
// Output answers
for(int i=0; i<=x;i+=3){
output.println(i + " ");}
// clean up output buffer
output.flush();
}
}
Re: Hey guys i've been trying to write this program for ages please Help!!
I think you would need i-- somewhere in there to decrement the integer one at a time.
Is that what you want to do, so say 10 is entered you want to print, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0
Or
are you reading in a set of numbers and just reversing the order of how the numbers were typed.
''reverse an order of numbers starting with the input and working it's way down"
Could you break this down further if possible ?
How many numbers you want to read in as the input ?
When exactly the input will terminate ?
What you want to do with each individual number ? or do with a collection of numbers.
etc. etc.
Im just confused with the "working its way down" part you say.
Re: Hey guys i've been trying to write this program for ages please Help!!
well it would be going down from the inputted number like if i inputted 24 and this program goes down in 3 then i would like it to 24,21,18,15,12,3,6,3,0 like that but i tried the i-- and i got an infinite loop unless i have to put in another loop then it wont work u get me?