import java.io.*;

public class k
{

    public static void main(String args[])throws IOException 
    {
      k s1 = new k();
      s1.menu();

    }        
    public void menu()throws IOException
{
    int input = 0;

System.out.println("Pick from 1 of the following Options");
System.out.println("1) Twelve");
System.out.println("5) Exit ");
System.out.println("Enter Number: ");

BufferedReader br;
br = new BufferedReader( new InputStreamReader( System.in ));//gathers data from user 
input = Integer.parseInt(br.readLine());

 k Jimmy = new k();
    if(input == 1)
        {
            Jimmy.twelve();//twelve method
        }
        else if(input == 5)
        {

           System.exit(0);{ // exit the program

        } }
        else {

           System.exit(0); // exit the program

        }
    }


public void twelve()throws IOException
{

    //**********somebody heeeelllllllllllllllp******************
 //Write a METHOD to read in a collection of integer values, and find and print 
 //the index of the first occurrence and last occurrence of the number 12. 
 //The program should print an index value of 0 if the number 12 is not found. 
  //The index is the sequence number of the data item 12. 
  //For example if the eighth data item is the only 12, then the index value 8 should be printed for the first and last occurrence. 

//Use if statements and while Loops
//Variable first 
//Variable last 
//Boolean , already found the 1st 12
     //**********help java guys******************


    k s1 = new k();
    s1.menu();


}
}

Recommended Answers

All 2 Replies

The data would probably be inside an array. Write a write-loop that reads the array and checks every element if it is 12. Then break from the loop because you only need the first. After you print the result then write another while-loop that reads the array backwards and does the same thing.

On a side-note, change your class name and variable names to something less meaningless. Descriptive names for classes, variables, and methods are immensely helpful to both you and others who read the code.

Also, after 22 posts here you should get familiar with [code] [/code] tags and use them.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.