What am I doing wrong? Java IllegalFormatConversionException

后端 未结 3 474
不思量自难忘°
不思量自难忘° 2021-01-13 17:50

I have some code for calculating properties of a circle:

package circleinfo;

import java.util.Scanner;

public class Circleinfo {

    public static void ma         


        
3条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-13 18:24

    (r*2) will be an int and not a float as r is int and 2 is int. Use %d instead

    %c          char    Character
    %d          int         Signed decimal integer.  
    %e, %E      float       Real number, scientific notation (lowercase or uppercase exponent marker)
    %f         float    Real number, standard notation.
    

提交回复
热议问题