Hello, I am currently working on a school project and ran into a little bit of trouble.
Every time I compile the program I get 2 errors they are:

cirlce.java:23: incompatible types
found : java.io.IOException
required: char
letter = get.ioException();
^

cirlce.java:37: possible loss of precision
found : double
required: int
a = pi*r*r;
^

Ive tried everything i could think of. Thank you for looking and helping.

// By:
// Circle program
import java.io.IOException;
import java.util.Scanner;

public class cirlce
{
    public static void main(String []args)throws IOException
    {
	 
	 Scanner get = new Scanner(System.in);
	 double pi = 3.14159265;
	 int d;
	 int c;
	 int a;
	 float r;
	 char letter;
	 
	 System.out.println("Please enter the radius in floating point form: ");
	 r = get.nextFloat();
	 
	 System.out.println("Please enter A for Area, D for Diameter, C for Circumfrence: ");
	 letter = get.ioException();
	
	
	if(letter == 'd');
	{ 
	 d = 2*(int)r;  
	 System.out.println("The area of a circle with radius " + r + "is" + d + "Square units");
	}
	if(letter == 'c');
	{
	 c = 2*(int)pi*(int)r;
	 System.out.println("The area of a circle with radius " + r + "is" + c + "Square units");
	}
	if(letter == 'a');
	{
	 a = pi*r*r;
	 System.out.println("The area of a circle with radius " + r + "is" + a + "Square units");
	}
	
	}
}

Edited 6 Years Ago by Blax: n/a

irlce.java:23: incompatible types
found : java.io.IOException
required: char
letter = get.ioException();
^

The error message says it all.
What does the get object's ioException() method return? Is it the same type as the variable letter?
What are you using the ioException() method for?

lce.java:37: possible loss of precision
found : double
required: int
a = pi*r*r;
^
The expression on the right of = is double. The variable on the left is int. There will be loss or precision. For example: 3.14159265 would be truncated to 3

The ioException() was supposed to return the letter given. Im really not shure what it suppposed to do :P

But i change the variable a into a double

Edited 6 Years Ago by Blax: n/a

Read the API doc for the class and its methods to see which might be useful to you.

ioException() was supposed to return the letter given

The doc says: Returns the IOException last thrown by this Scanner's underlying Readable.
How could anyone think that was a letter?

I thought it was supposed to throw out the error a.k.a look past it and still except the letters.

to throw out the error

Does that translate to "ignore the error"?
Anyway java is strict on types. The type of the object returned by ioException() is NOT a char.

Edited 6 Years Ago by NormR1: n/a

Yes, it translates to "ignore the error"
Ok i understand that now thank you for explaining that to me

im sorry but i still dont get this can you please help me? Online you can email me back at Corynn60@gmail.com or Corynn60@yahoo.com

Look at the date. This post is 2 years old.

Start your own thread if you have a question.

online we can email him at ....
personally, haven't met anyone yet who could email offline.
@NiallLover: if you still "don't get this", read the earlier answers, they actually do explain it all.

This article has been dead for over six months. Start a new discussion instead.