Design a child function, according to a given radius of integer data, calculate the area of a circle (return parameter is real), is the main function in assignment statement calls to display the results for an argument, you can just write the core algorithm,
Here is to write their own code, but the code demands sub function results of real Numbers, hope leaders help Package zz0224;
Public class SSS { Private static final double PI=3.14; Public static int the add (double r) { Return (int) (PI * r * r); } Public static void main (String [] args) { Int r=4, Sum=0; Sum=add (r); System. The out. Print (" the area of a circle="+ sum); } }
?
CodePudding user response:
The return value is written is wrong, if you want to return with the decimal number, can't return an int, to return to double