Results 1 to 8 of 8

Thread: Incopatable types [Resolved]

Threaded View

  1. #1

    Thread Starter
    Lively Member OT²O's Avatar
    Join Date
    Jan 2010
    Location
    Washington State
    Posts
    96

    Resolved Incopatable types [Resolved]

    Hey I am working on a school project and I need help with 3 errors I keep getting when I compile.

    I have this array storing my strings.
    Code:
    private String[] months = {"January", "Febuary", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"};
    and I need the program to Return the Month that rainfall is the greatest.
    Code:
    		public double getHighestMonth(){
    			double highest = values[0];
    			String month = months[0];
    		
    			for (int index = 1; index < values.length; index++){
    				if (values[index] > highest)
    					highest = values[index];
    					month = months[index]; 
    			}
    		
    			return month;
    		}
    Here is the errors I am receiving.
    Code:
    RainFall.java:35: incompatible types
    found   : java.lang.String
    required: double
    			return month;
    			       ^
    RainFall.java:40: incompatible types
    found   : java.lang.String
    required: double
    			double month = months[0];
    			                     ^
    RainFall.java:45: incompatible types
    found   : java.lang.String
    required: double
    				month = months[index];
    				              ^
    3 errors
    Any help would be greatly appreciated.
    Last edited by OT²O; Jan 18th, 2011 at 03:42 AM. Reason: resolved
    On the off chance that I helped you (Rate This Post){
    Also If your problem was resolved;
    }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width