0
Rahatsız ettiğim için üzgünüz ama skoru sayan bir sınav uygulaması yapıyorum. Ancak puanım görüntülendiğinde 0 gösteriliyor.Java ile küçük bir sorun yaşıyorsanız.
Değişkenlerimde bir sorun var mı?
Düzeltmek için bir yolu var mı?
package quiz;
import java.util.Scanner;
public class quiz {
public static void main(String[] args) {
//–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
//User input
Scanner in = new Scanner(System.in);
//User input
//–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
//SCORE
int score = 0;
//SCORE
//–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
//Yes or No
String yn;
//Yes or No
//––––––––––––––––––––––––––––––––––––––––––––––––––––
String q1 = "Is the hottest chili on earth called the Carolina Reaper(y/n)?";
String q2 = "Was beethoven the father of mosart(y/n)?";
String q3 = "Is the worlds best sellng album the Thriller(y/n)?";
String q4 = "Was Steve Jobs the maker of microsoft(y/n)?";
String q5 = "Did Steve jobs Die(y/n)?";
String q6 = "Was the first Iphone the Iphone 2(y/n)?";
String q7 = "Was Rich Miner the only developer of android (y/n)?";
String q8 = "Is the Goliath tarantula the biggest spider on earth(y/n)?";
String q9 = "Is Octopus wolfi the biggest octopus on earth(y/n)?";
String q10 = "Adolph Blaine Charles David Earl Frederick Gerald Hubert Irvin John Kenneth Lloyd Martin Nero Oliver Paul Quincy Randolph Sherman Thomas Uncas Victor William Xerxes Yancy Wolfeschlegelsteinhausenbergerdorff Broke the record for the most confusing name(y/n)?";
//QUESTIONS
System.out.println(q1);
yn = in.nextLine();
if (yn == "y"){
score++;
}
System.out.println(q2);
yn = in.nextLine();
if (yn == "y"){
score++;
}
System.out.println(q3);
yn = in.nextLine();
if (yn == "y"){
score++;
}
System.out.println(q4);
yn = in.nextLine();
if (yn == "y"){
score++;
}
System.out.println(q5);
yn = in.nextLine();
if (yn == "y"){
score++;
}
System.out.println(q6);
yn = in.nextLine();
if (yn == "y"){
score++;
} System.out.println(q7);
yn = in.nextLine();
if (yn == "y"){
score++;
} System.out.println(q8);
yn = in.nextLine();
if (yn == "y"){
score++;
} System.out.println(q9);
yn = in.nextLine();
if (yn == "y"){
score++;
} System.out.println(q10);
yn = in.nextLine();
if (yn == "y"){
score++;
}
System.out.println("Awesome, you scored "+ score +"/10");
}
}
Teşekkür: Burada
kodudur!Kodum özensizse üzgünüm, yeni başlayan biriyim.
Çok çok geniş. Oku [oku] ve kodunuzu nasıl ayıklayacağınızı öğrenin. – Amit
Biçimlendirmenizi bir kısayol tuşu ile düzeltmek için IDE'nizi kullanabilirsiniz. Ayrıca Dizeleri'nin içeriğini karşılaştırmak için '==' kullanmamalısınız. –