hi, this is a program where you type a name of a class and it gives a brief description, what i want to do is after it gives the description of a class it goes back to the beginning of the script and asks you to enter another one. How can i do that? thanks :)

import java.util.Scanner;
public class WoW
{
public static void main(String[] args)
{
String classname;
Scanner inputDevice = new Scanner(System.in);
System.out.println("Welcome");
System.out.println("Please enter a WoW class");
classname = inputDevice.nextLine();
if(classname.equalsIgnoreCase("rogue"))
{
System.out.println("A rogue uses stealth and daggers to destroy it's opponent.");
}
else if(classname.equalsIgnoreCase("hunter"))
{
System.out.println("A hunter can tame beasts and is a master with a bow.");
}
else if(classname.equalsIgnoreCase("warrior"))
{
System.out.println("A warrior is everyones friend, they focus all enemy damage on themselves.");
}
else if(classname.equalsIgnoreCase("warlock"))
{
System.out.println("A warlock calls upon dark magic to cause pain and fear in it's targets.");
}
else if(classname.equalsIgnoreCase("druid"))
{
System.out.println("A druid is at one with nature and can transform into many animals.");
}
else if(classname.equalsIgnoreCase("paladin"))
{
System.out.println("A paladin calls upon the light to heal his allies and smite his foes.");
}
else if(classname.equalsIgnoreCase("mage"))
{
System.out.println("A mage is a master of three schools of magic, arcane, fire, and frost.");
}
else if(classname.equalsIgnoreCase("shaman"))
{
System.out.println("A shaman is a versatile being, deadly with melee and spells.");
}
else if(classname.equalsIgnoreCase("priest"))
{
System.out.println("A priest calls upon the light as a paladin but is more gifted in Holy Magic.");
}
else
{
System.out.println("Invalid Class Entry");
System.out.println("Program terminated.");
}
}
}

You mean once it is done your program should ask him for another class and so on. What you need to do is to use a menu and keep returning to it. So the menu should be printed in a while loop which has a termination clause that the user would enter when he no longer wants to go on. Say for example your main menu would look something like this:
1. Enter a Class to be described
2. Exit

Here you execute the while loop (or a do-while one if you think the user would want atleast one class description everytime) till the user enters the option 2, for which you just terminate the program.

While you are at it, I suggest rather then using your current way of allowing the user to enter the name of the class wherein the user has a chance to make a typo, you use another menu inside the main one. which lists out all the classes for description.

Something like:
1. Rogue
2. Hunter
3. Warrior and so on...

So that instead of entering the class name the user just has to enter the number associated with it. This menu would be printed once the user selects option 1 from the first (main) menu.

i'm afraid i haven't gotten into while loops yet, could you show me some code example of a while loop? and how would i fit it into my code?

You could use this tutorial for it. But if you haven't been taught while loops then maybe you are not supposed to use them till yet.

This article has been dead for over six months. Start a new discussion instead.