i am trying to learn italian and i thougth that memorising the basic words would be a good idea. so i built a program that randomly chooses a word and asks what that word means in english. this is how the program looks:
package övningar;
import java.util.Random;
import java.util.Scanner;
public class italian {
public static void main(String[] args) {
String Ital[] = {"io","tu","lui","lei","noi","voi"}; //italian words
String Eng[] = {"i","you","he","she","we","you all"}; // english words
Scanner Input = new Scanner(System.in);// input scanner
int num;// the variable that holds the random number
String answer;// the variable that holds the answer
Random words = new Random(); //generator
while(true) {
num = words.nextInt(6); // generating
System.out.println("what is ´" + Ital[num] + "´ in english? :"); //asking what the word means in english
answer = Input.nextLine(); // input to question
if(Eng[num] == answer){ //checking to see if the answer is correct
System.out.println("that's correct \n");
}
else
if( Eng[num] != answer) // checking to see if the answer is false
System.out.println("that's incorrect, ´" + Ital[num] + "´ = ´" + Eng[num] + "´ in english \n");
else//exiting the program if no answer is received
System.exit(0);
}
}
}
butt every time i execute the program the allways says the its incorrect. i don't know what im doing wrong, please someone help me!
Aucun commentaire:
Enregistrer un commentaire