How to implement mathematical expression in Java?

Illegal Start of Expression Java Arrays/Methods?

  • import jaa.util.Scanner; public class Assignment7 { public static void main(String [] args) { int[] testData = new int[] {10, 20, 30, 40, 50, 60}; getTotal(testData); getAverage(testData); getHighest(testData); getLowest(testData); public static void getTotal(int Total[]{10, 20, 30, 40, 50, 60} ) { for(int count = 1; cout < Total.length; count++) Total += total; System.out.println(Total); } public static void getAverage(int Average[]{10, 20, 30, 40, 50, 60}) { int total = 0; for(int count = 1; count < Average.length; count++) total += Average; Average = total / 2; System.out.println(Average); } public static void getHighest(int Highest[]{10, 20, 30, 40, 50, 60}) { for(int count = 1; count < Highest.length; count++) { if(Highest[index] > Highest) Highest = Highest[index]; } System.out.println(Highest); } public static void getLowest(int Lowest[]{10, 20, 30, 40, 50, 60}) { for(int index = 1; index < numbers.length; index++) { if(numbers[index] < lowest) lowest = numbers[index]; System.out.println(Lowest); } } } } ----jGRASP exec: javac -g Assignment7.java Assignment7.java:17: illegal start of expression public static void getTotal(int Total[]{10, 20, 30, 40, 50, 60} ) ^ Assignment7.java:53: ';' expected } ^ 2 errors why do i keep getting this syntax error?

  • Answer:

    You actually have more than 2 errors. When you correct one, you will get more. Note that this is not the correct way to declare your method - you have: public static void getTotal(int Total[]{10, 20, 30, 40, 50, 60} ) The correct way is: public static void getTotal(int Total[] )

Jessie at Yahoo! Answers Visit the source

Was this solution helpful to you?

Other answers

Kenneth is correct, you will need to change the arguments for each of your methods. However the error that you have right now is because you dont have a '}' that ends your main method. public static void main(String [] args) { int[] testData = new int[] {10, 20, 30, 40, 50, 60}; getTotal(testData); getAverage(testData); getHighest(testData); getLowest(testData); Should be public static void main(String [] args) { int[] testData = new int[] {10, 20, 30, 40, 50, 60}; getTotal(testData); getAverage(testData); getHighest(testData); getLowest(testData); }

Jordan

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.