I just wanna be able to input 10 integer numbers, display the numbers, then be able to modify a specific number I have already entered, then display the new updated numbers again.

//Date: 4/6/2010

import java.io.*;

public class EnterNumbers 
{
	public static void main(String[] args) throws IOException
	{
		BufferedReader dataIn = new BufferedReader (new InputStreamReader(System.in));
		int[] intValue = new int[10];
		String[] numbers = {"first", "second", "third", "fourth", "fifth", "sixth", "seventh", "eighth", "ninth", "tenth"};
		
		for (int i = 0; i < intValue.length; ++i)
		{
			System.out.println("Enter the " + numbers[i] + " number");
			intValue[i] = Integer.valueOf(dataIn.readLine());
		}
		System.out.println("The numbers you entered are ");
		for (int x = 0; x < intValue.length; ++x)
			if (intValue[x] == intValue[9])
				System.out.print(intValue[x]);
			else
				System.out.print(intValue[x] + ",  ");
		
		System.out.println("\nWould you like to modify a number you entered?");
		char yesno = (char)System.in.read();
		if (yesno == 'Y' || yesno == 'y')
		{
			System.out.println("Out of the 10 numbers you entered, which number do you wanna modify? (1-10)");
			int input = Integer.parseInt(dataIn.readLine());
			for (int x = 0; x < intValue.length; ++x)
			if (input == intValue[x])
			{
				System.out.println("What do you want to change the number to?");
				int number = Integer.parseInt(dataIn.readLine());
				for (int n = 0; n < intValue.length; ++n)
					if (number == intValue[x])
					System.out.print(intValue[x]);
			}
					
		}
		else
			System.exit(0);
	}
	
}

What am I missing??

I don't know - what are you missing? Did you do any debugging? You listed some steps:

1. input 10 integer numbers,
2. display the numbers,
3. modify a specific number I have already entered,
4. display the updated numbers again.

Which of those steps isn't working?

System.out.println("Out of the 10 numbers you entered, which number do you wanna modify? (1-10)");
			int input = Integer.parseInt(dataIn.readLine());
			for (int x = 0; x < intValue.length; ++x)
			if (input == intValue[x])
			{
				System.out.println("What do you want to change the number to?");
				int number = Integer.parseInt(dataIn.readLine());
				for (int n = 0; n < intValue.length; ++n)
					if (number == intValue[x])
					System.out.print(intValue[x]);
			}
 
		}
		else
			System.exit(0);

This code is where it gets weird. I'm not sure how to tell the program, here, this is the array number 0-9 with a new array of [10], that I want to change, which I want the user to enter 1-10 of the ten they entered, and then tell the program what I want the new number to be of the specific array number I requested (0-9). And then redisplay the array numbers with the new modified number I made. Make sense?

ystem.out.println("Out of the 10 numbers you entered, which number do you wanna modify? (1-10)");
			int input = Integer.parseInt(dataIn.readLine());

is this even what I'm supposed to write for inputting the user input for which array number (0-9) they wanna modify?
I wanna say something like

if (input == intValue[input])

but that always gives me an error with an OutOfBoundsException. if I play with what the code stand now, The only output I will get at the end of the program for 'redisplaying the numbers with the modified number' is the

10

like I'm asking it to display the last array number placement instead of what the 10(or 9) represents (any integer number inside it).

Am I making sense?

From the book:
The first part of the exercise: Write a program letting the user enter numbers (1 through 9) one at a time, and print the numbers the user entered. Store the numbers in an array.
This first part was very easy!!!

part 3: Let the user delete or modify a number. Include a menu that shows the options to enter, remove, modify, or display a number, or quit the program. Change the program so that when the user chooses the modify option, the program prompts the user to specify which number to modify. Verify that the user enter a valid number (0-9), ask for the new number, verify that the user enters a valid number, and then change the number in the array.

Example for user input is just enter 10 random integer numbers like: 33, 44, 2, 10, 99, 156, 256, 77, 45, 56. Then ask the user if they wanna modify any of the numbers, of course to do that, I have to tell it which number (0-9) to modify then input a new number into that place, then redisplay the numbers with updated number. Like I wanna change the number 156, which is in the 6th spot in the array, but number 5 because all arrays start with 0, change the number to .......66, then redisplay: 33, 44, 2, 10, 99, 66, 256, 77, 45, 56......with 66 as the new number.

Edited 6 Years Ago by musikluver4: n/a

for (int x = 0; x < intValue.length; ++x)

Should probably be

for (int x = 0; x < intValue.length; x++)

The same for your other for loop. That is more than likely the reason you're getting the exception.

Actually, all I did was substitution to make my array index input assigned to the number I wanted to change

//Date: 4/6/2010

import java.io.*;

public class EnterNumbers 
{
	public static void main(String[] args) throws IOException
	{
		BufferedReader dataIn = new BufferedReader (new InputStreamReader(System.in));
		int[] intValue = new int[10];
		String[] numbers = {"first", "second", "third", "fourth", "fifth", "sixth", "seventh", "eighth", "ninth", "tenth"};
		
		for (int i = 0; i < intValue.length; ++i)
		{
			System.out.println("Enter the " + numbers[i] + " number");
			intValue[i] = Integer.valueOf(dataIn.readLine());
		}
		System.out.println("The numbers you entered are ");
		for (int x = 0; x < intValue.length; ++x)
			if (intValue[x] == intValue[9])
				System.out.print(intValue[x]);
			else
				System.out.print(intValue[x] + ",  ");
		
		System.out.println("\nWould you like to modify a number you entered?");
		char yesno = (char)System.in.read();
		System.in.read();
		
		if (yesno == 'Y' || yesno == 'y')
		{
			System.out.println("Out of the 10 numbers you entered, which number do you wanna modify? (1-10)");
			int index = Integer.parseInt(dataIn.readLine());
			
			System.out.println("What will the new number be?");
			int number = Integer.parseInt(dataIn.readLine());
			intValue[index] = number;
			
			for (int x = 0; x < intValue.length; ++x)
				System.out.print(intValue[x] + " ");
			
			
					
		}
		else
			System.exit(0);
	}
	
}

As you see, this is what I did

int index = Integer.parseInt(dataIn.readLine());
			
System.out.println("What will the new number be?");
int number = Integer.parseInt(dataIn.readLine());
intValue[index] = number;
			
for (int x = 0; x < intValue.length; ++x)
System.out.print(intValue[x] + " ");

I just told it right here with a substitution

intValue[index] = number;
This question has already been answered. Start a new discussion instead.