问答详情
源自:3-2 Java中的算术运算符

找大神解答下

运行失败

HelloWorld.java:14: error: cannot find symbol
		System.out.println("自减后的年龄:"+newAge);
		                             ^
  symbol:   variable newAge
  location: class HelloWorld
1 error


提问者:Wayne_Wang 2019-02-28 14:57

个回答

  • weixin_慕盖茨5555608
    2019-05-17 00:37:28

    public class HelloWorld{

        public static void main(String[] args) {

    int age1=24;

    int age2=18;

    int age3=36;

    int age4=27;

    int sum=24+18+36+27;

    double avg=sum/4;

    int minus=24-18;

    int newAge=--age1;

        System.out.println("年龄总和:"+sum);

        System.out.println("平均年龄:"+avg);

    System.out.println("年龄差值:"+minus);

    System.out.println("自减后的年龄:"+newAge);


    }


  • wj961127
    2019-03-14 16:17:34

    public class HelloWorld{

        public static void main(String[] args) {

    int age1=24;

    int age2=18;

    int age3=36;

    int age4=27;

    int sum=age1+age2+age3+age4;

    double avg=(age1+age2+age3+age4)/4;

    int minus=age1-age2;

    int newAge=--age1;

        System.out.println("年龄总和:"+sum);

        System.out.println("平均年龄:"+avg);

    System.out.println("年龄差值:"+minus);

    System.out.println("自减后的年龄:"+newAge);


    }

    }


  • 爱冒险的梦ya
    2019-02-28 15:16:52

    把代码都贴上来呀