0
itzkloive's Avatar, Join Date: Mar 2008
Newbie Member
Can some one help a novice

I am kinda teaching myself java and got stuck trying to create a a program to translate 10 words bi-directional from english to spaniah, using two different String Arrays one consist of english words and one consist of spanish words. Can someone help this novice out?


import java.io.*;//tell Java we are using java.io libary.
import java.util.*;//Java utility package also for Scanner class

public class transWords //Naming the program.
{

public static void main(String[ ]args)throws Exception
{
//This set-up allow for user to input using keyboard.
Scanner input= new Scanner(System.in);


//Declaring Array String.
String[]englishTrans={"color","white","blue","green","blac k","purple",};
//Declaring Array String.
String[]spanishTrans={"en color","blanco","azul","verde","negro","purpúreo", };
0
pradeep's Avatar, Join Date: Apr 2005
Team Leader
What's the exact nature of help you are looking for? the code snippet is probably incomplete!
0
shilpa dessai's Avatar, Join Date: Mar 2008
Newbie Member
hi Pradeep,
For sorting a 1D array we used the simply Bubble sort aLgorithm which worked perfectly fine...but we cant write the code 4 the 2D array as we had written earlier....
thx...
Shilpa
0
Mazharul's Avatar, Join Date: Aug 2008
Newbie Member
sir,
i want to show a 2D array corresponding to a .jpg/.gif/.png image file in a separate window. suppose i have...
class Image {
protected int width,height;
// 'samples' stores the image pixel values.
protected int[][] samples;
// Constructor: Reads the image from the
// specified file name.
public Image(String filename)
throws Exception { read(filename); }
// Returns the pixel width of the image.
public int getWidth() { return width; }
// Returns the pixel height of the image.
public int getHeight() { return height; }
// Reads the image from the specified file
// name into the 'samples' array. Throws an
// exception if the image is stored in an
// unsupported file format (currently only
// .GIF, .JPG, and .PNG are supported by Sun).
public void read(String filename)
throws Exception {
// Extract the file name suffix...
.......
...........
.............
from the startup java file like..
import java.awt.*;
import javax.imageio.*;
class TestImage {
public static void main(String args[])
throws Exception {
// Create a frame to display the image.
Frame frame = new Frame("Test Image");
frame.setSize(1024,768);
frame.setVisible(true);
Graphics gc = frame.getGraphics();
try {
// Read the image from the file.
Image img = new Image("Horse.jpg");
.........

I want to access the int [][] samples array then want to disply this array values in a separate windo or applet..How to approach......
0
majidpucit123's Avatar, Join Date: Sep 2008
Newbie Member
i'm trying to create a method that adds an element in an existing string array. Kind of like the arraylist "add()" method.
so far, i have this

String[] addToArray(String[] strArray1, String s)
{
return strArray1+s;

}



but this doesnt work...
why?
0
pradeep's Avatar, Join Date: Apr 2005
Team Leader
There already exists such a method, it's called push!
0
new2Java's Avatar, Join Date: Dec 2008
Newbie Member
Hi!

I need to compare 2 words in a given name and see if any part of the name in index [0] (first name and/or surname) matches the rest of the names. For instance,

robert smith | robert mathews | john robert | john roberts

Basically, only the first and lastname in the first index ("robert smith") needs to be compared with rest of the first and the last names. '

How do I go about this?

I'm successful in comparing just 1 word. eg: robert|RoBERT|smith
boolean result1= choiceKeys[0].equalsIgnoreCase (choiceKeys[i+1]);

What should I do when I have 2 words?

Thanks in advance,
-new2Java
0
thusha's Avatar, Join Date: Aug 2009
Newbie Member
Hai
I am inteested in adding elements to 2D array.
So i do like this
i have always one input as prod id ; where i get from parameter

then the for loop
Code:
int n = productsid;
                  
                               for( row=0;row<10;row++) {              	
            	year2007[n][row] = (float) tot;
               }
but when i display my array
i dont get the prod id?? what ican do ??
0
Theone's Avatar, Join Date: Dec 2009
Newbie Member
Hi Pradeep,
Can you use a 2d array to make a chess board and store the pieces within it?.
0
technica's Avatar, Join Date: Dec 2007
CoderByNature
Thanks for posting. A article on handling arrays for sorting and searching would be great.