49% . import java.io. import java.util. class atob public static void main(Strin
ID: 3689161 • Letter: 4
Question
49% . import java.io. import java.util. class atob public static void main(String argsD String word new String[2][11] String aw.bw=" ",temp; word[0][0]-"attic", word 1 [0]="loft". word[0][1 ]="business suit";word( 1 ][ 1 ]="lounge suit"; word[0][2elevator";word[1 ][2lift"; word[0][3]--flashlight";word( 1 ][3]="torch". word[0][4]="gasoline".word( 1 ][4]= "petrol". word[0][5]-"ice cream"word[[Sice", word[0][6)--megaphone".word[ ! ][6]="loud hailer"; word[01I7 radioword[][7]-"wireless" word[0][8]-"sneakers"-word[1 ][8]-"plimsolls", word[0](9)-"truck-.word( 1 191orry..; word[0][1 0]="zero"word[1 ][1 0)-"nought"; System.out.println"n enter the american word: "); Scanner in new Scanner(System.in); aw=in.nextL.ne(); for int i -0;iilit+) if(aw.compareTo( word[0][i])==0) bw word[ Ii] System.out.println"word not found"); else System.out,println"british word is " +bw) 5 C:UsersSARATHCHANDRAdesktop chegg> java atob enter the american word: ritish word is loft attic s C:Users SARATHCHANDRA desktop chegg java atob enter the american word: ord not found 5S C:Users SARATHCHANDRAdesktop cheggExplanation / Answer
import java.util.Random;
public class atob {
/**
* @param args
*/
public static void main(String[] args) {
String words[][] = new String[2][11];
words[0][0] = "attic";
words[1][0] = "loft";
words[0][1] = "bussiness suit";
words[1][1] = "longue suit";
words[0][2] = "elevator";
words[1][2] = "lift";
words[0][3] = "flash light";
words[1][3] = "torch";
words[0][4] = "gasolite";
words[1][4] = "petrol";
words[0][5] = "ice cream";
words[1][5] = "ice";
words[0][6] = "megaphone";
words[1][6] = "loud hailer";
words[0][7] = "radio";
words[1][7] = "wireless";
words[0][8] = "sneakers";
words[1][8] = "plimsols";
words[0][9] = "truck";
words[1][9] = "lorry";
words[0][10] = "zero";
words[1][10] = "naught";
// random instance
Random rand = new Random();
// repeat five times to get translation
for (int i = 0; i < 5; i++) {
int randomNum = rand.nextInt(11);
System.out.println((i + 1) + ". American Word :"
+ words[0][randomNum] + " British wod is "
+ words[1][randomNum]);
}
}
}
OUTPUT:
1. American Word :truck British wod is lorry
2. American Word :bussiness suit British wod is longue suit
3. American Word :elevator British wod is lift
4. American Word :gasolite British wod is petrol
5. American Word :attic British wod is loft
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.