I have an Illegal start to an expression. I'm trying to remove it so these methods can be implanted.

import java.io.*;
import java.text.*;


public class Kudo
{
public static void main(String args[])throws IOException


{
do
{
System.out.println("pick from 1 of the following options");
System.out.println("1) twelve");
System.out.println("2) minMaxAvg");
System.out.println("5) to exit");


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


Kudo Jimmy = new Kudo();
if(input == 1)
{
Jimmy.twelve();//method
}


else if(input == 2)
{
Jimmy.minMaxAvg();//method
}


while(input !=5)
{


}



public void twelve() //Illegal start of EXPRESSION is HERE, basically at the 1st METHOD



//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


{


}


public void minMaxAvg()


{
//Write a METHOD to find the minimum, maximum, and average values of a collection of data values. The number of data values is unspecified.
//Take in a collection
}


public void grades()


{
int input = 0;
int integer = 0;
int sumA = 0;
int sumB = 0;
int sumC = 0;
int sumD = 0;
int sumF = 0;


System.out.println("please enter score[-99 to quit:]");//Prompt user to enter data
BufferedReader br;
br = new BufferedReader( new InputStreamReader( System.in ) );//gathers data from user
input = Integer.parseInt(br.readLine());// Integer.parseInt method here which calls the readline() method off of it



if(input==-99) System.exit(1);


while(input != -99){ //keep looping as long as the input is not equal to -99


if(input>=90 ){//if input is Greater than or EQUAL to 90 the grade is an A
sumA++; //when an input of 90 or greater is inputed, 1 is incremented in the SUM for the value of A(sumA)
System.out.println(input + "      A");
}
else if(input >= 70){//if input is Greater than or EQUAL to 70, and not =90,  the grade is a B
sumB++;//when an input of 70 or greater is inputed, 1 is incremented in the SUM for the value of B(sumB)
System.out.println(input + "      B");
}
else if(input >= 50){
sumC++;
System.out.println(input + "      C");
}
else if(input >= 35){
sumD++;
System.out.println(input + "      D");
}
else{
sumF++;//when an input of 34 or lower is inputed, 1 is incremented in the SUM for the grade of F (sumF)
System.out.println(input + "      F");
}



System.out.println("please enter ANOTHER score[-99 to quit:]");
input = Integer.parseInt(br.readLine());// Integer.parseInt method here which calls the readline() method off of it



}


System.out.println("The total number of A's is " + sumA );
System.out.println("The total number of B's is " + sumB );
System.out.println("The total number of C's is " + sumC );
System.out.println("The total number of D's is " + sumD );
System.out.println("The total number of F's is " + sumF );
}


public void product()
//Write a METHOD that will find the product of a collection of data values.
//The program should ignore all negative values and terminate when a zero value is encountered.
//Use a String Tokenizer to take in values


{
System.out.println("I am in the product method");
}
}

Recommended Answers

All 6 Replies

You haven't ended the main() method block. Until you do that you can't start a new method.

You haven't ended the main() method block. Until you do that you can't start a new method.

Who do I do that?

Just like you end any other method - with a brace.

That part is for you to figure out. Methods cannot be defined within other methods, so each method block must be defined separately within the class.

Just count how many braces you have opened and how many you have closed. Make sure that when you open a brace you must close. So don't open a brace, start writing and then after lots of code try to remember where to close it.
What you should do is whenever you open something, immediately close it and then write the code inside it. That also includes parenthesis. Also this is also possible:

{
  {
  }

  {
  }
}

Meaning that when you try to close the braces you must make sure that all the other braces inside it are closed
One last tip: When you open a new brace write it a <tab> or a few spaces to the right than the previous brace:

{
  {
  }
  
  {
    {
    }
  }
}

That way you can monitor better what you open and close

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.