473,463 Members | 1,515 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Please help me about this array Program code

Output:
Enter a Value: //x6
Menu
1. Search
2. Locate for an index
Choice:

//if chosen 1: sample//
Enter a value to search: 6
6
//else if not available//
Number not found

//if chosen 2: sample//
Enter a value to search index: 6
//else if not available//
Number not found

//here is my program code//
import java.util.Scanner;
public class Program1
{
public static void main(String[]args){
Scanner read=new Scanner(System.in);
int num[][], r, c, a, e;
num=new int[2][3];
for(r=0; r<=1; r++)
{
for(c=0; c<=2; c++)
{
System.out.print("Enter a value: ");
num[r][c]=read.nextInt();
}
}
System.out.println("Menu");
System.out.println("1. Search");
System.out.println("2. Locate for an index");
System.out.print("Choice: ");
a=read.nextInt();
switch(a)
{
case 1:
System.out.print("Enter a value to search: ");
e=read.nextInt();
for(int b=0; b<=1; b++)
{
for(int d=0; d<=2; d++)
{
if(e==num[b][d])
{
System.out.println(num[b][d]);
break;
}
}
}
System.out.println("Number not found");
break;
case 2:
System.out.print("Enter a value to search: ");
e=read.nextInt();
for(int b=0; b<=1; b++)
{
for(int d=0; d<=2; d++)
{
if(e==num[b][d])
{
System.out.println(num[b][d]+" is on index "+b+", "+d);
break;
}
}
}
}
}
}
Jan 23 '10 #1
1 1357
Curtis Rutland
3,256 Expert 2GB
So what is your specific problem?
Jan 25 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Roy J | last post by:
Hello everyone:) My name is Roy, I am new to Java and I have problem regarding to arrays. if you have time and like to help, please help. I am trying to make a program to deal with prime...
1
by: djinni | last post by:
It's been a while since I've written anything in C, and I was hoping to get some feedback on the following code. As far as I can tell, the program works fine, but I'm not sure I'm cleaning all the...
6
by: Buck Rogers | last post by:
Hi guys! Love your work! The below program is from K&R2, p22. ================================= #include <stdio.h> /* count digits, white space, others */ main() {
3
by: s.subbarayan | last post by:
Dear all, I encountered the following piece of program: #include <stdio.h> void strprint(char *str); void main() { char *spr="hello"; strprint(spr); }
10
by: napsterrafay | last post by:
Write a program that will define an integer array test of size 10. The program will read values into the array test through keyboard from the user. After reading into the array test the program...
2
by: varusnyc | last post by:
Hello, I've been struggling with this assignment for very long now. I'm not even sure how to start the code right, as well as the structure of it. My code is a complete mess, and Im not sure what...
3
NewYorker
by: NewYorker | last post by:
Hello brothers and sisters, Please help me complete this program and get the output shown below. Here is all I have ___________________________________________________________ This...
5
by: weidongtom | last post by:
Hi, I tried to implement the Universal Machine as described in http://www.boundvariable.org/task.shtml, and I managed to get one implemented (After looking at what other's have done.) But when I...
9
by: weidongtom | last post by:
Hi, I've written the code that follows, and I use the function add_word(), it seems to work fine *before* increase_arrays() is called that uses realloc() to allocate more memory to words. But...
5
by: mohammaditraders | last post by:
Write a program which overloads a binary Minus (-) operator, The program will contain a class Matrix, This class will contain a private data member Array which store int values. The class will...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.