javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Read the input from the keyboard by using the Scanner class. Search for examples. As for the rest you need to provide some more information.
For example, will you have to enter each character after the other or you will need to enter one word and then take that word and put its characters into one char array?

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Actually I find that kind code confusing and I never use it. This is simpler:

// get the first line of the file. If it is not null go in the loop
String aLine = infile.readLine();
while (aLine != null) {

  // the line is not null. So you can do whatever you want to process it
  System.out.println(aLine);

..........

  // at the end of the loop. At the LAST command, read the next line:
  aLine = infile.readLine();
  // if the next line is null, then the loop will exit and you finish reading the file.
  // that is why it must be at the end.
}

At the last command you read the next line, then you go at the top of the loop. If that line is null then there is no line, and you don't continue looping.

Another, more stupid way, is this. Though I don't recommend it:

while (true) {
  String aLine = infile.readLine();
  if (aLine==null) {
     System.out.println("No more lines. Will exit the loop");
     break;
  }
  // no else needed here because if you go in the above if, you will break from the loop and nothing else will execute.
  // with the break command you exit the loop

  System.out.println("Line:"+aLine);
}
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Sorry forgot to post code.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

it's a copy and pasted question people..

That doesn't mean anything. Post your code with specific questions. Open a book and follow the examples.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Add a Double object as attribute and when you get it, cast it to Double. Look at the java API for the class: java.lang.Double. It's a class like any other. Don't let its name confuse you. It's a class with methods and attributes.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

If it is database, read some tutorials about it and post some code. Search for database connectivity with java

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

The session is one. That is what it does. If you had set the attributes to the request then you would be able to access them only from one page to the other. But if you put them to the session, you can access them from any page, no matter how many times you submit or redirect.
There is only one session.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

After you have run the query, use the ResultSet and a while loop to save the results in a Vector. Then you can do whatever you want with the Vector at your servlet or jsp.

I suggest you study first how to run queries and get the results with java, which has nothing to do with jsps.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Try to empty the second combo box before adding any more dates from the first combo.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

What are those 1 and 5? Function[n][0] < 1 || Function [n][0] > 5 They are suppose to by dynamic. The user is the one that enters those values. 1 nad 5 have no meaning. Why any function must be between those ranges? Couldn't it be this function:
f(50)=100
f(100)=1000

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

When looping arrays, an array of length: name.length() , has indexes from 0 to name.length()-1.
An array of length 3 has arr[0], arr[1], arr[2], not arr[3]
So the for loop shouldn't be: for (int i = 0; i <= name.length(); i++)

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

What do you mean: "should never rewrite total content."
And what would be the format of your file. Meaning what would its content be?
What are the rest of your requirements?

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

You can try the sun's tutorials.
Personally I had a beginner's book about java that had a chapter on how to make gui and how clicking buttons work

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

First of all, have you been told how will you need to read the input?
If it is ok to read the Names separately then you are fine.
If it is required to read once the whole string with the words then you can do what I suggested.
Remember, you can loop the String and get each character with that method. You can use the String.length() method to find the upper limit of the index.

My suggestion was:

"
You might want to loop the String and use the charAt to take each character, using the charAt. Have a new String an initialize it outside the for loop.
In the loop once you find an empty character, means that you have finished with a word so the next character is the first letter of the next word. Concatenate only the next character to the String.
"

If you can use any method to help you then you can use the split method, that will give you the words of the String in an array:

String s = "Dani A. Ona";
String [] tok = s.split(" ");

// tok now is an array with elements:
// tok={"Dani", "A.", "Ona"}

Now you can loop that array and get the first character of each element, but you need to make sure that you are allowed to use that method. Maybe not if you said that you can use only the charAt.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

@javaaddict, yes i ran the program...and its alright.
i have a question...
if i will input my name once, not in separate ones...
if i will use the if statement, then my program can read the first letter, but how can my program read the rest of my initials, and output them?

@Akill, yes i got the code from the net
then the program you said, i wrote it.. :)
i do not... copy and paste :)

You mean if you have a String like this: "aaa bbb cc" how can you get the initials?

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

I didn't know that the user could enter the names separately. It is much easier that way. Have you tried running the program?

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

charAt is a method of the String class. In case you don't know it:

String s = "abs";
char ch = s.charAt(0);
System.out.println(ch);

You might want to loop the String and use the charAt to take each character, using the charAt. Have a new String an initialize it outside the for loop.
In the loop once you find an empty character, means that you have finished with a word so the next character is the first letter of the next word. Concatenate only the next character to the String.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Have you written any code or, you used exclusively the gui builder for that?

You should learn how to code those events. How to add action listeners to your buttons. You need to read some tutorials and try to make that gui on your own.
Just declare those components and add them to your main JFrame.
Classes you will need:
javax.swing.JText (for text fields)
javax.swing.JLabel (for labels)
javax.swing.JButton (for buttons)

Check the API for their methods and constructors.

And if you are a beginner then this project way too much for you. You will one main JFrame with buttons like a menu where you need to select if you want to add a new contact or view the existing ones. Those would be independent classes/JFrames. Once one of those buttons is clicked you need to call its class by creating a new instance of that JFrame and display it.

Assuming you have classes for adding and viewing that extend JFrame: JView.java, JAdd.java.
Then depending on the button clicked:

JView view = new JView(); // JView extends JFrame
view.setVisible(true); // method inherited from JFrame
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Declare that variable public, or better have public get methods:

class ClassA {
  private int value = 0;

  public int getValue() {
     return value;
  }
}
class ClassB {
  
   public static void main(String [] args) {
      ClassA cla = new ClassA();
      System.out.println(cla.getValue());
   }
}
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Your query is wrong. Do some studying about sql. If you want to use ? and prepared statements don't use quotes. Use this:

"Select * from pin_numbers where pin_number like ?"

pst.setString(1,pin);

If you want to search rows that have this: "twt000" inside their value, then this '*' will not work with sql.
Use:

"Select * from pin_numbers where pin_number like '%" + pinnumber + "%'";

Not prepared statement.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Use javascript. When the button is clicked make that value empty. Assign an id attribute to the text field and use it to take the field as an object.

<input type="text" value="A" id="id_A" name="someName" />

javscript:

document.getElementById("id_A").value="";

Check these tutorials:
http://www.w3schools.com/default.asp

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

can you gave us a running program about selection sort that the user will input something from the keyboard...thank you...

NO.

Start a new thread. There are plenty of examples on how to read input with the Scanner class. Start a new thread with some code.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

what else do you have in that jsp ?

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Assuming that you have this javascript function:

<head>
<script>
  function abc(arg) {
...
  }
</script>
</head>

And in the jsp you have:

<body>
<%
..
// get patientmodel
%>

<input type="button" name="but" value="Click me" onclick="abc('<%=patientmodel.getpatient()%>');" />

</body>

Or you can use it in any other way. But you cannot use javascript to change the value of java variable.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Another good thing would be to check if the line you are trying to parse has that tag.
First call the indexOf method. If it returns -1 then the line doesn't have that tag <text> , so continue with the next line.

An in case that the line has more than one tag:
Line = <text>aa</text><text>bbb</text>
You can put that in a loop and take the next indexOf that tag. There is method that also takes as argument an int that indicates from where you want to start searching (indexOf("string", int))

But better leave that for last and handle simple cases first.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Do have the JAVA_HOME environment variable set. After doing some searching, and now I remember that I had the same problem, I found that you have to put first the latest java version that you are using when declaring that variable. You must also set your classpath correctly in order to use the latest java version when compiling and running

After very little search, I found this page:
http://www.devdaily.com/blog/post/java/java-lang-unsupportedclassversionerror/

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Post some code.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

I wrote my version using your code. I used the JPanel class. I declared it as an attribute of the class so I can have access to it in the method that handles the double clicking.

package stam.bar;

import java.awt.event.*;
import javax.swing.*;

public class SimpleFrame extends JFrame implements MouseListener {
    private JLabel lb1 = new JLabel("Hi 1");
    private JLabel lb2 = new JLabel("Hi 2");
    private JLabel lb3 = new JLabel("Hi 3");

    private JPanel panel = new JPanel();
    
    public SimpleFrame() {
        setSize(300, 300);
        
        lb1.addMouseListener(this);
        lb2.addMouseListener(this);
        lb3.addMouseListener(this);
        
        panel.add(lb1);
        panel.add(lb2);
        panel.add(lb3);
        
        add(panel);
    }

    public static void main(String[] args) {
        SimpleFrame simpleFrame = new SimpleFrame();
        simpleFrame.setVisible(true);
    }
    
    public void mouseClicked(MouseEvent e) 
    {
        if (e.getClickCount() == 2)  
        {
            if (e.getComponent()!=null) {
                panel.remove(e.getComponent());
                repaint();
            }
        }
    }

    public void mousePressed(MouseEvent e) {
    }

    public void mouseReleased(MouseEvent e) {
    }

    public void mouseEntered(MouseEvent e) {
    }

    public void mouseExited(MouseEvent e) {
    }
}

I my version I add the mouse listeners directly to the components: lb3.addMouseListener(this);

LianaN commented: thanks. +1
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Search any tutorial or open any basic book.
Also this is very important. Don't rely on the free solutions of the internet. If you want to study and learn, buy a book.

And in another thread you said that you have already studied the basics. It is not our job to teach here the language step by step. You need to put effort and study yourself.

Anyway, in order to declare a method:

public [static] <return_type> methodName(arguments or empty) {

}

[] : that is optional

public static int methodName(int a, String b, ...... ) {
  ....
  return 0; // since it is declared to return int
}
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

yes that's right I wanna the code of the keyListener???
and moving could be timer..

Code For KeyListener

You could have also found that on the net

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

If you want to make a game where a spaceship moves and fires, you will require skills far beyond that simple code that you wrote.

Do you know how to handle events in GUI?

It is not something that you can do in a day, or expect others to give you a little hint and then do the entire thing. You will need lots of code. Code that none of us is willing to write for you.

Even if you want to write it by yourself, you need to show more effort and more code on your behalf. Check some tutorials on how to handle events and control moving objects.
There are a lot of things that can not be told here and you need to study them.

Also if you say that MouseInputListener doesn't work what code did you write to use it?

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

computation1 is a static method of the class metod. You need to call it like this: metod.computation1(arguments)

Also you haven't declared the methods correctly in the metod class.

Try to read some tutorials on how to create and call methods.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

It is obviously that even the %d that you use is correct, the %lf is not.
Try to use this: %f.
And check this link for more information:
http://download.oracle.com/javase/1.5.0/docs/api/java/util/Formatter.html#syntax

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

I hsve error as identifier expeced error at
"synchronize public void static debit(float ba)" this line plz reply as early as possible

class Demo
{

    Acc a1,a2;
String tot;
    AccU au1,au2;
    public static void main(String args[])  
    {
    a1=new Acc(1000,10000);
    a2=new Acc(50,50000);
    au1=new Acc(a1,"Ganesh","d");
    au1=new Acc(a2,"Vinayak","c");
    }
}
class AccU extends Thread
{
Acc u1;

String name,tot1;
    AccU(Acc u2,String na,String tot2)
    {
        u1=u2;
        name=na;
        tot1=tot2;

    }   


    public void run()
    {
    u1.start();
    u1.join();  
    if(tot1.equals("d"))
    u1.debit(u1.bal);           

    if(tot1.equals("c"))
    u1.crdt(u1.bal);    

    }

}

class Acc
{
    int acno;
    float bal,crbal;

    Acc(int an,float b)
    {
    acno=an;
    bal=b;
    }


    synchronize public void  static debit(float ba)
        {
        System.out.println("Bal before trans="+ba);
        crbal=crbal+ba;
        System.out.println("Bal after trans="+crbal);
        bal=crbal;
        }

    synchronize static public void  static crdt(float ba)
    {
    System.out.println("Bal before trans="+ba);
    crbal=crbal-ba;
    System.out.println("Bal after trans="+crbal);
    bal=crbal;
    }

} 

end quote.

I think the error is with the order of your declaration:
It is "public static void" . Also I don't believe that you spelled synchronize correctly. Also check some tutorials as where you need to place it when declaring a method

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Use code tags when posting code. Click the button code and put your code inside.
Then explain your problem. What errors do you get?

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Try to read line by line. Use the methods hasNextLine and readLine. Then save that line into a String.
Once you have the String, use the method indexOf(String) and find where the "<text>" and "</text>" are found. Then use the substring method.
All the above methods can be found at the java.lang.String API.

Remember:
<text>aaaa</text>
012345678910

The indexOf method, will return 0 when you search for the "<text>", so in order to get the "aaaa", you will need to do subString(0+6, 10)
Where 0 and 10 would be the values that the indexOf method will return

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Also it is better to use the setVisible(true) method instead of the show method in your main.

Does the code that you have compiles and runs successfully? If yes what is your question?
Do you know how to use Listeners ?

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

What error message and are you sure that the query is valid? Have you tried to run in at the MySql command prompt ?

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Try using the equals method instead of the '=='. You need to override that method in your classes.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

We don't know what this "Assault fleet" game is, even if we were willing to write the code for you.
Explain what you want to do and wait for our suggestions

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

I think it would be wrong where you put the return statement. With that way, the method will return at the very first for loop iteration. Because the if the first time would normally be false, so it will immediately return.
And I don't know if it will compile, because the return is inside the for loop. In general, it is not certain that the execution will enter the loop so the return might not execute.

You must put the return outside the for loops. And have it return what your method is suppose to do in the case that the if or in general the loop does not execute.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

The code works for me. Does the message display correctly? ("there is a value")
Can you post an image of the gui that you see.
Also is the image file at the correct path. ("image.jpg") . Have you tried the full path?
Also have you tried setting the size of the frame? frame.setSize(400, 400); Also just because the icon is not null, doesn't mean that the image file exists. Whatever you put as file, the instance would be created and it would be not null even if the image does not exist

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Do you get any errors when the server stops. Can you add some messages to be printed before it stops?

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

For writing I use this:
BufferedWriter, FileWriter:

BufferedWriter wr = null;
try {
   wr = new BufferedWriter(new FileWriter("Exercise09_19.txt"));

   wr.write("something");
} catch (Exception e) {
  System.out.println(e.getMessage());
} finally {
  if (wr!=null) wr.close();
}

The BufferedWriter is declared outside the try, in order to be "visible" in the finally when we close it. But initialized in the try because it throws an exception. Since the close also throws an exception, you should try this:

BufferedWriter wr = null;
try {
   wr = new BufferedWriter(new FileWriter("Exercise09_19.txt"));

   wr.write("something");
} catch (Exception e) {
  System.out.println(e.getMessage());
} finally {
  try {if (wr!=null) wr.close();} catch (Exception e) {}
}

Write to the file and then review it. I would suggest to put wr.write("something") in your loop. Meaning that all your loop would be in the try - catch.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

?

missing return statement!


hi guys,

Im trying to compile this class below, but its just not working, it keeps sating 'missing return statement' int the method declaration line. Can u see to check if there is anything missing in my code or if iv done something wrong??

Thanks!


public class swapping {

public int trade(int []a, int b){ //says theres a missing return statement
int temp=0;
for (int n = 1; n < b; n++) {
for (int m = 0; m < b - 1; m++) {
if (a[m] > a[m] + 1) {
temp = a[m];
a[m] = a[m+1];
a[m+1] = temp;
return a[m];
}
}
}
}empty program!
}

You have the return in the 'if'. What happens if the 'if' doesn't execute. The method doesn't have any other return statement. It will not return if it doesn't go in the 'if'. You must have a return for all the cases, if you have lots of 'if' statements:

if () {
  ...
  return ;
} else if () {
  ...
  return ;
}
// if both the above are false, no if will be executed so no 'return ;' , you need to add one more outside the ifs and any other whiles, loops switches, ...
return ;
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Hi JavaAddict
I am trying to get the solution and I think I have it but...I need to solve a small problem with javascript arrays. Appear some undefined values and I dont get how eliminate these.
here the code:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
 <HEAD>
 
 </HEAD>

 <BODY>
 <FORM METHOD=POST ACTION="" name="solicitud" id="frm1">
	
 <TABLE>
 <TR>
	<TD> <TEXTAREA id='text' NAME="text1"  ></TEXTAREA></TD>
	<TD> <INPUT id='check' TYPE="checkbox" NAME="check1"></TD>
 </TR>
 <TR>
<TD> <TEXTAREA id='text' NAME="text2" ROWS="" COLS="" disabled></TEXTAREA></TD>
	<TD> <INPUT id='check' TYPE="checkbox" NAME="check2"></TD>
 </TR>
 <TR>
	<TD> <TEXTAREA id='text' NAME="text3" ROWS="" COLS="" disabled></TEXTAREA></TD>
	<TD> <INPUT id='check' TYPE="checkbox" NAME="check3"></TD>
 </TR>
 <TR>
<TD> <TEXTAREA id='text' NAME="text4" ROWS="" COLS="" disabled='disabled'></TEXTAREA></TD>
	<TD> <INPUT id='check' TYPE="checkbox" NAME="check4" ></TD>
 </TR>
 </TABLE>
 </FORM>

 
 <script type="text/javascript">

var x=document.getElementById("frm1");
var j=x.length;
var texto=document.getElementsByTagName("TEXTAREA");
var check=document.getElementsByTagName("INPUT");
var jhon=new Array();
var jhon1=new Array();

alert(texto.length+" "+check.length);

for (var i=0;i<j;i++)
  {
  if(x.elements[i].id=="check"){
	jhon[i]=x.elements[i].name;
  }else if(x.elements[i].id=="text"){
	jhon1[i]=x.elements[i].name;
  }
  }

for (var r=0;r<jhon.length;r++)
  {
	 document.write(jhon[r]+"  "+ jhon1[r]);
	 document.write("<br />");
  }
alert(jhon.length);
alert(jhon1.length);

</script>

 </BODY>
</HTML>

Is a simple example, please run it and see the result then you will understand better.

Muchas Gracias

What are you trying to accomplish with that code. Because there is no need to take the form as an object: document.getElementById("frm1") and you can use the same method to get the Text Area.
Also check the API of those elements that you get and see what attributes they have:
http://www.w3schools.com/jsref/default.asp

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

loop the String and take each character and append it to a new string until you find a ',' character. If the charAt(i) is not ',' concatenate it to a new String, else simply display the string and continue the loop to take the next word.
You might want to make that string empty again in order to add the other characters from the beginning.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

what is the meaning of the word ophane case......

Post again the code in code tags. And where do you get that error?

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster
import java.util.*;
 
public class List3{
private final int [] arr;
private final int MAX=10;

	public List3(){
	arr=new int[MAX];
	}//ACCEPT 10 NUMBERS
	public void accept(){
	Scanner console=new Scanner(System.in);
	for(int i=0;i<arr.length;i++)
	arr[i]=console.nextInt();
	}
		public int smallest(){
		int	smallest=0;
		for(int i=0;i<arr.length;i++)
		smallest=Math.min(smallest,arr[i]);
		return smallest;
		}	
			public int largest(){
			int largest=0;
			for(int i=0;i<arr.length;i++)
			largest=Math.max(largest,arr[i]);
			return largest;
			}
		public int sum(){
		int sum=0;
		for(int i=0;i<arr.length;i++)
		sum+=arr[i];
		return sum;
		}//main
		public static void main(String [] args){
		
 
		 do {
 print_menu
 userChoice = take_from_keyboar;

 switch (userChoice) {

 }


	case 1: System.out.println("Enter the smallest number for list1");
			 System.out.println("Enter the largest number for list1");
			 break;
	case 2: System.out.println("Smallest of list1="+list1.smallest());
			 System.out.println("Largest of list1="+list1.largest());
			 break;
	case 3: System.out.println("Smallest of list2="+list2.smallest());
			 System.out.println("Largest of list2="+list2.largest());
			 break;
	case 4: public void display(){
			 for(int i=0;i<arr.length;i++)
			 System.out.println(arr[i]+"");
			 System.out.println();
			 }
			 break;
			 
	case 5: System.out.println("Smallest of list1="+list1.smallest());
			 System.out.println("Largest of list1="+list1.largest());
			 break;
			 System.out.println("Smallest of list2="+list2.smallest());
			 System.out.println("Largest of list2="+list2.largest());
			 break;

	case 6: //is should be the quit i dont how to make it
	
					}
}

please people do check it.

print_menu and take_from_keyboar are not java commands. Use your imagination.
And post the errors that you get.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

yeah i know that,but what i just dont how put it in there..i dont how to arrange in that way.....please do help me...edit my code and post it...please i was really stack in here.....thanks....

The code is already edited:

do {
  // print the menu. Use System.out.println

  int userChoice = // use the scanner class to get the input
  
  switch (userChoice) {
    // add your code here
    // add the case statements you have written
  }

} while (userChoice != EXIT_LOOP_NUMBER)

If you get errors, which you will, post them here with your new code.
Since the methods were declared non static, you will need to create a new instance of the class:

main() {

List3 list3 = new List3();
// use the list3 instance to call the methods in the cases. The arr array declared and initialized in the constructor would be the you would be using with the methods. No need to create a new one inside the main.

do {
  // print the menu. Use System.out.println

  int userChoice = // use the scanner class to get the input
  
  switch (userChoice) {
    // add the case statements you have written
    case 1:
       ....
       break;
    ....
  }

} while (userChoice != EXIT_LOOP_NUMBER)

}