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", };
|
Newbie Member
|
|
| 23Mar2008,19:51 | #11 |
|
Team Leader
|
![]() |
| 23Mar2008,22:33 | #12 |
|
What's the exact nature of help you are looking for? the code snippet is probably incomplete!
|
|
Newbie Member
|
|
| 26Mar2008,18:34 | #13 |
|
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 |
|
Newbie Member
|
|
| 11Aug2008,14:18 | #14 |
|
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...... |
|
Newbie Member
|
|
| 9Sep2008,12:24 | #15 |
|
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?
|
|
Team Leader
|
![]() |
| 9Sep2008,14:16 | #16 |
|
There already exists such a method, it's called push!
|
|
Newbie Member
|
|
| 10Dec2008,03:41 | #17 |
|
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 |
|
Newbie Member
|
|
| 13Aug2009,13:20 | #18 |
|
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;
}
i dont get the prod id?? what ican do ?? |
|
Newbie Member
|
|
| 17Dec2009,18:30 | #19 |
|
Hi Pradeep,
Can you use a 2d array to make a chess board and store the pieces within it?. |
|
CoderByNature
|
|
| 18Dec2009,09:58 | #20 |
|
Thanks for posting. A article on handling arrays for sorting and searching would be great.
|

