Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: Help With errors. Please.

  1. #1
    Junior Member
    Join Date
    Mar 2012
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Help With errors. Please.

    I need help compiling my code in Java. I have a couple errors. Thanks for the help.



    My code:

     
        31  public class WeekTemp {
        32
        33  public static void main(String[] args) {
        34  char[] ref = createArray();
        35
        36
        37
        38  System.out.println("Enter a integer between 1 and 52 to indicate the week of the year: ");
        39  displayArray(ref);
        40
        41  int[] counts = countLetters(chars);
        42
        43  System.out.println();
        44  System.out.println("The 10 reference values for the week are: ");
        45  displayCounts(counts);
        46
        47
        48  public static char[] createArray() {
        49  
        50  char[] ref = new char[52];
        51  
        52  for (int i = 0; i < chars.length; i++)
        53  chars[i] = Random
        54  
        55  public class WeekTemp {
        56  
        57  public static void main(String[] args) {
        58  
        59  // declares an array of integers
        60  
        61  int[] anArray;
        62  
        63  // allocates memory for 10 integers
        64  
        65  anArray = new int[10];
        66  
        67  // initialize first element
        68  
        69  anArray[0] = 100;
        70  
        71  // initialize second element
        72  
        73  anArray[1] = 200;
        74  
        75  // etc.
        76  
        77  anArray[2] = 300;
        78  anArray[3] = 400;
        79  anArray[4] = 500;
        80  anArray[5] = 600;
        81  anArray[6] = 700;
        82  anArray[7] = 800;
        83  anArray[8] = 900;
        84  anArray[9] = 1000;
        85  
        86  System.out.println("Reference value 0: "
        87  + anArray[0]);
        88  System.out.println("Reference value 1: "
        89  + anArray[1]);
        90  System.out.println("Reference value 2: "
        91  + anArray[2]);
        92  System.out.println("Reference value 3: "
        93  + anArray[3]);
        94  System.out.println("Reference value 4: "
        95  + anArray[4]);
        96  System.out.println("Reference value 5: "
        97  + anArray[5]);
        98  System.out.println("Reference value 6: "
        99  + anArray[6]);
       100  System.out.println("Reference value 7: "
       101  + anArray[7]);
       102  System.out.println("Reference value 8: "
       103  + anArray[8]);
       104  System.out.println("Reference value 9: "
       105  + anArray[9]);
       106  }
       107  }
       108  
       109  public static double rms(double[] nums){
       110  double ms = 0;
       111  for (int i = 0; i < nums.length; i++)
       112  ms += nums[i] * nums[i];
       113  ms /= nums.length;
       114  return Math.sqrt(ms);
       115  }
       116  
       117  public static void main(String[] args){
       118  double[] nums = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0};
       119  System.out.println("The 5 RMS deviations are: + rms(nums)");
       120    }
       121   }
       122  }


    Errors:


     
    % javac WeekTemp.java
     
    WeekTemp.java:48: illegal start of expression
    public static char[] createArray() {
    ^
    WeekTemp.java:55: ';' expected
    public class WeekTemp {
           ^
    WeekTemp.java:109: illegal start of expression
    public static double rms(double[] nums){
    ^
    WeekTemp.java:121: ';' expected
     }
     ^
    4 errors
    %
    Last edited by wrx12; March 11th, 2012 at 11:46 AM. Reason: added numbers to code.


  2. #2
    Junior Member
    Join Date
    Mar 2012
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Help With errors. Please.

    Well, what are you trying to do in the first place? It'd be a lot more helpful if we knew the reason behind what the code actually does.
    EDIT: And well, line 53 just sets each element to "Random", I'm not sure if that got cut off while pasting, but, that definitely doesn't make sense.
    Last edited by SupportIsPower; March 11th, 2012 at 11:49 AM.

  3. #3
    Junior Member
    Join Date
    Mar 2012
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Help With errors. Please.

    The arrays obs[] and ref[] are each 10 elements long, with obs[] representing the 10 different readings taken on a given day in the plant. Now, the values of the 10 elements in obs[] change every day of the five-day week but for a given week, the ref[] values are the same. These can be thought of fixed values to be adhered to for a whole week, but the fixed values are different for different weeks. The goal is to find the total deviation for a given week.

Similar Threads

  1. Replies: 3
    Last Post: March 6th, 2012, 03:50 AM
  2. GUI errors
    By cindisue in forum What's Wrong With My Code?
    Replies: 1
    Last Post: March 30th, 2011, 09:54 AM
  3. Many Errors
    By Woody619 in forum What's Wrong With My Code?
    Replies: 10
    Last Post: July 16th, 2010, 09:36 PM
  4. Getting errors
    By Nonire in forum What's Wrong With My Code?
    Replies: 7
    Last Post: July 4th, 2010, 12:21 PM
  5. Why am I getting 62 errors?
    By DestinyChick1225 in forum What's Wrong With My Code?
    Replies: 4
    Last Post: July 1st, 2010, 04:41 AM