dimanche 22 février 2015

How to repeat a string using if.. I want to let the program if they say yes

Please look at the bottom, you can see there my mistake =)



import java.util.Scanner;
public class BlueJPeriodicalExam {
static Scanner key = new Scanner(System.in);
public static void main(String[] args) {

System.out.println("Greetings, user!");
System.out.println("Please type your name:");
String a = key.nextLine();
System.out.println("");

System.out.println("Please choose from the following: things, names, or places");
String choice= key.next();
System.out.println("");
if(choice.equals("things")) System.out.println("You chose things.");
if(choice.equals("names")) System.out.println("You chose names.");
if(choice.equals("places")) System.out.println("You chose places.");
System.out.println("");

System.out.println("Please type any letter from A-Z.");
String b = key.next();
System.out.println("");
if(b.equals("a"))
{
if(choice.equals("things")) System.out.println("Find an Arrow.");
if(choice.equals("names")) System.out.println("You voted for Albert Einstein.");
if(choice.equals("places")) System.out.println("Please visit America.");
System.out.println("");
}
if(b.equals("A"))
{
if(choice.equals("things")) System.out.println("Find an Arrow.");
if(choice.equals("names")) System.out.println("You voted for Albert Einstein.");
if(choice.equals("places")) System.out.println("Please visit America.");
System.out.println("");
}
if(b.equals("b"))
{
if(choice.equals("things")) System.out.println("Find a Bag.");
if(choice.equals("names")) System.out.println("You voted for Barry Allen.");
if(choice.equals("places")) System.out.println("Please visit Britain.");
System.out.println("");
}
if(b.equals("B"))
{
if(choice.equals("things")) System.out.println("Find a Bag.");
if(choice.equals("names")) System.out.println("You voted for Barry Allen.");
if(choice.equals("places")) System.out.println("Please visit Britain.");
System.out.println("");
}
if(b.equals("c"))
{
if(choice.equals("things")) System.out.println("Find a Cabinet.");
if(choice.equals("names")) System.out.println("You voted for Caitlyn Snow.");
if(choice.equals("places")) System.out.println("Please visit Canada.");
System.out.println("");
}
if(b.equals("C"))
{
if(choice.equals("things")) System.out.println("Find a Cabinet.");
if(choice.equals("names")) System.out.println("You voted for Caitlyn Snow.");
if(choice.equals("places")) System.out.println("Please visit Canada.");
System.out.println("");
}
if(b.equals("d"))
{
if(choice.equals("things")) System.out.println("Find a Door.");
if(choice.equals("names")) System.out.println("You voted for Dexter Santos.");
if(choice.equals("places")) System.out.println("Please visit Denmark.");
System.out.println("");
}
if(b.equals("D"))
{
if(choice.equals("things")) System.out.println("Find a Door.");
if(choice.equals("names")) System.out.println("You voted for Dexter Santos.");
if(choice.equals("places")) System.out.println("Please visit Denmark.");
System.out.println("");
}
if(b.equals("e"))
{
if(choice.equals("things")) System.out.println("Find an Eraser.");
if(choice.equals("names")) System.out.println("You voted for Eddie Thawne.");
if(choice.equals("places")) System.out.println("Please visit England.");
System.out.println("");
}
if(b.equals("E"))
{
if(choice.equals("things")) System.out.println("Find an Eraser.");
if(choice.equals("names")) System.out.println("You voted for Eddie Thawne.");
if(choice.equals("places")) System.out.println("Please visit England.");
System.out.println("");
}
if(b.equals("f"))
{
if(choice.equals("things")) System.out.println("Find a Fence.");
if(choice.equals("names")) System.out.println("You voted for Felicity Smoak.");
if(choice.equals("places")) System.out.println("Please visit Finland.");
System.out.println("");
}
if(b.equals("F"))
{
if(choice.equals("things")) System.out.println("Find a Fence.");
if(choice.equals("names")) System.out.println("You voted for Felicity Smoak.");
if(choice.equals("places")) System.out.println("Please visit Finland.");
System.out.println("");
}
if(b.equals("g"))
{
if(choice.equals("things")) System.out.println("Find a Grinder.");
if(choice.equals("names")) System.out.println("You voted for Galileo Galilei.");
if(choice.equals("places")) System.out.println("Please visit Greenland.");
System.out.println("");
}
if(b.equals("G"))
{
if(choice.equals("things")) System.out.println("Find a Grinder.");
if(choice.equals("names")) System.out.println("You voted for Galileo Galilei.");
if(choice.equals("places")) System.out.println("Please visit Greenland.");
System.out.println("");
}
if(b.equals("h"))
{
if(choice.equals("things")) System.out.println("Find a Hairbrush.");
if(choice.equals("names")) System.out.println("You voted for Harrison Wells.");
if(choice.equals("places")) System.out.println("Please visit Hong Kong.");
System.out.println("");
}
if(b.equals("H"))
{
if(choice.equals("things")) System.out.println("Find a Hairbrush.");
if(choice.equals("names")) System.out.println("You voted for Harrison Wells.");
if(choice.equals("places")) System.out.println("Please visit Hong Kong.");
System.out.println("");
}
if(b.equals("i"))
{
if(choice.equals("things")) System.out.println("Find an Instrument.");
if(choice.equals("names")) System.out.println("You voted for Isaac Newton.");
if(choice.equals("places")) System.out.println("Please visit Ireland.");
System.out.println("");
}
if(b.equals("I"))
{
if(choice.equals("things")) System.out.println("Find an Instrument.");
if(choice.equals("names")) System.out.println("You voted for Isaac Newton.");
if(choice.equals("places")) System.out.println("Please visit Ireland.");
System.out.println("");
}
if(b.equals("j"))
{
if(choice.equals("things")) System.out.println("Find a Jar.");
if(choice.equals("names")) System.out.println("You voted for James Chadwick.");
if(choice.equals("places")) System.out.println("Please visit Japan.");
System.out.println("");
}
if(b.equals("J"))
{
if(choice.equals("things")) System.out.println("Find a Jar.");
if(choice.equals("names")) System.out.println("You voted for James Chadwick.");
if(choice.equals("places")) System.out.println("Please visit Japan.");
System.out.println("");
}
if(b.equals("k"))
{
if(choice.equals("things")) System.out.println("Find a Kite.");
if(choice.equals("names")) System.out.println("You voted for Konrad Lorenz.");
if(choice.equals("places")) System.out.println("Please visit Korea.");
System.out.println("");
}
if(b.equals("K"))
{
if(choice.equals("things")) System.out.println("Find a Kite.");
if(choice.equals("names")) System.out.println("You voted for Konrad Lorenz.");
if(choice.equals("places")) System.out.println("Please visit Korea.");
System.out.println("");
}
if(b.equals("l"))
{
if(choice.equals("things")) System.out.println("Find a Log.");
if(choice.equals("names")) System.out.println("You voted for Luise Andrei Pilar.");
if(choice.equals("places")) System.out.println("Please visit Libya.");
System.out.println("");
}
if(b.equals("L"))
{
if(choice.equals("things")) System.out.println("Find a Log.");
if(choice.equals("names")) System.out.println("You voted for Luise Andrei Pilar.");
if(choice.equals("places")) System.out.println("Please visit Libya.");
System.out.println("");
}
if(b.equals("m"))
{
if(choice.equals("things")) System.out.println("Find a Map.");
if(choice.equals("names")) System.out.println("You voted for Michael John D Cunanan.");
if(choice.equals("places")) System.out.println("Please visit Manchester.");
System.out.println("");
}
if(b.equals("M"))
{
if(choice.equals("things")) System.out.println("Find a Map.");
if(choice.equals("names")) System.out.println("You voted for Michael John D Cunanan.");
if(choice.equals("places")) System.out.println("Please visit Manchester.");
System.out.println("");
}
if(b.equals("n"))
{
if(choice.equals("things")) System.out.println("Find a Notebook.");
if(choice.equals("names")) System.out.println("You voted for Nariszah Montecillo.");
if(choice.equals("places")) System.out.println("Please visit Norway.");
System.out.println("");
}
if(b.equals("N"))
{
if(choice.equals("things")) System.out.println("Find a Notebook.");
if(choice.equals("names")) System.out.println("You voted for Nariszah Montecillo.");
if(choice.equals("places")) System.out.println("Please visit Norway.");
System.out.println("");
}
if(b.equals("o"))
{
if(choice.equals("things")) System.out.println("Find an Oven.");
if(choice.equals("names")) System.out.println("You voted for Oliver Quinn.");
if(choice.equals("places")) System.out.println("Please visit Oman.");
System.out.println("");
}
if(b.equals("O"))
{
if(choice.equals("things")) System.out.println("Find an Oven.");
if(choice.equals("names")) System.out.println("You voted for Oliver Quinn.");
if(choice.equals("places")) System.out.println("Please visit Oman.");
System.out.println("");
}
if(b.equals("p"))
{
if(choice.equals("things")) System.out.println("Find a Pan.");
if(choice.equals("names")) System.out.println("You voted for Philip Phillips.");
if(choice.equals("places")) System.out.println("Please visit Philippines.");
System.out.println("");
}
if(b.equals("P"))
{
if(choice.equals("things")) System.out.println("Find a Pan.");
if(choice.equals("names")) System.out.println("You voted for Philip Phillips.");
if(choice.equals("places")) System.out.println("Please visit Philippines.");
System.out.println("");
}
if(b.equals("q"))
{
if(choice.equals("things")) System.out.println("Find a Quantum Splicer.");
if(choice.equals("names")) System.out.println("You voted for Quilla Ford.");
if(choice.equals("places")) System.out.println("Please visit Qatar.");
System.out.println("");
}
if(b.equals("Q"))
{
if(choice.equals("things")) System.out.println("Find a Quantum Splicer.");
if(choice.equals("names")) System.out.println("You voted for Quilla Ford.");
if(choice.equals("places")) System.out.println("Please visit Qatar.");
System.out.println("");
}
if(b.equals("r"))
{
if(choice.equals("things")) System.out.println("Find a Rug.");
if(choice.equals("names")) System.out.println("You voted for Robbie Amell.");
if(choice.equals("places")) System.out.println("Please visit Russia.");
System.out.println("");
}
if(b.equals("R"))
{
if(choice.equals("things")) System.out.println("Find a Rug.");
if(choice.equals("names")) System.out.println("You voted for Robbie Amell.");
if(choice.equals("places")) System.out.println("Please visit Russia.");
System.out.println("");
}
if(b.equals("s"))
{
if(choice.equals("things")) System.out.println("Find a Sharpener.");
if(choice.equals("names")) System.out.println("You voted for Sona Raymond.");
if(choice.equals("places")) System.out.println("Please visit Singapore.");
System.out.println("");
}
if(b.equals("S"))
{
if(choice.equals("things")) System.out.println("Find a Sharpener.");
if(choice.equals("names")) System.out.println("You voted for Sona Raymond.");
if(choice.equals("places")) System.out.println("Please visit Singapore.");
System.out.println("");
}
if(b.equals("t"))
{
if(choice.equals("things")) System.out.println("Find a Telephone.");
if(choice.equals("names")) System.out.println("You voted for Tony Woodward.");
if(choice.equals("places")) System.out.println("Please visit Thailand.");
System.out.println("");
}
if(b.equals("T"))
{
if(choice.equals("things")) System.out.println("Find a Telephone.");
if(choice.equals("names")) System.out.println("You voted for Tony Woodward.");
if(choice.equals("places")) System.out.println("Please visit Thailand.");
System.out.println("");
}
if(b.equals("u"))
{
if(choice.equals("things")) System.out.println("Find an Umbrella.");
if(choice.equals("names")) System.out.println("You voted for Uriel Septum.");
if(choice.equals("places")) System.out.println("Please visit Ukraine.");
System.out.println("");
}
if(b.equals("U"))
{
if(choice.equals("things")) System.out.println("Find an Umbrella.");
if(choice.equals("names")) System.out.println("You voted for Uriel Septum.");
if(choice.equals("places")) System.out.println("Please visit Ukraine.");
System.out.println("");
}
if(b.equals("v"))
{
if(choice.equals("things")) System.out.println("Find a Violin.");
if(choice.equals("names")) System.out.println("You voted for Vigay Kumar.");
if(choice.equals("places")) System.out.println("Please visit Vietnam.");
System.out.println("");
}
if(b.equals("V"))
{
if(choice.equals("things")) System.out.println("Find a Violin.");
if(choice.equals("names")) System.out.println("You voted for Vigay Kumar.");
if(choice.equals("places")) System.out.println("Please visit Vietnam.");
System.out.println("");
}
if(b.equals("w"))
{
if(choice.equals("things")) System.out.println("Find a Wood.");
if(choice.equals("names")) System.out.println("You voted for William Shakespeare.");
if(choice.equals("places")) System.out.println("Please visit Washington D.C.");
System.out.println("");
}
if(b.equals("W"))
{
if(choice.equals("things")) System.out.println("Find a Wood.");
if(choice.equals("names")) System.out.println("You voted for William Shakespeare.");
if(choice.equals("places")) System.out.println("Please visit Washington D.C.");
System.out.println("");
}
if(b.equals("x"))
{
if(choice.equals("things")) System.out.println("Find a Xylophone.");
if(choice.equals("names")) System.out.println("You voted for Xin Zhao.");
if(choice.equals("places")) System.out.println("Please visit Xiao Pei Street.");
System.out.println("");
}
if(b.equals("X"))
{
if(choice.equals("things")) System.out.println("Find a Xylophone.");
if(choice.equals("names")) System.out.println("You voted for Xin Zhao.");
if(choice.equals("places")) System.out.println("Please visit Xiao Pei Street.");
System.out.println("");
}
if(b.equals("y"))
{
if(choice.equals("things")) System.out.println("Find a Yoyo.");
if(choice.equals("names")) System.out.println("You voted for Yamagato.");
if(choice.equals("places")) System.out.println("Please visit Yemen.");
System.out.println("");
}
if(b.equals("Y"))
{
if(choice.equals("things")) System.out.println("Find a Yoyo.");
if(choice.equals("names")) System.out.println("You voted for Yamagato.");
if(choice.equals("places")) System.out.println("Please visit Yemen.");
System.out.println("");
}
if(b.equals("z"))
{
if(choice.equals("things")) System.out.println("Find a Zipper.");
if(choice.equals("names")) System.out.println("You voted for Zayn Malik.");
if(choice.equals("places")) System.out.println("Please visit Zimbabwe.");
System.out.println("");
}
if(b.equals("Z"))
{
if(choice.equals("things")) System.out.println("Find a Zipper.");
if(choice.equals("names")) System.out.println("You voted for Zayn Malik.");
if(choice.equals("places")) System.out.println("Please visit Zimbabwe.");
System.out.println("");
}


I need your help in this part. The yes or no


I need your help in this part. The yes or no


I need your help in this part. The yes or no



System.out.println("Would you still like to continue? Type: yes or no");
String c = key.next();
System.out.println("");
if(c.equals("no"))
{
System.out.println("Thanks for cooperating with us " + a + ". You may now exit the program.");
}
if(c.equals("yes"))
{
//// I NEED YOU HELP IN HERE =)
}
System.out.println("");
}
}


Thanks for your help! Hope You can help me with this


Aucun commentaire:

Enregistrer un commentaire