gpt4 book ai didi

java - 我做了一个初学java "math"但不知道错误在哪里

转载 作者:行者123 更新时间:2023-12-01 06:54:59 24 4
gpt4 key购买 nike

我编写这些代码只是为了好玩,为了训练一点,因为我是一个 15 岁的 Java 初学者,但不知道问题出在哪里,也不知道在“lol”方法之后要放什么谢谢你的帮助

public class mathClass {

static int a = 10;
static int b = 15;
static int c = 22;
static int result = 0;
static double counter = 0.25;

public static void main(String[] args) {
double resultone;
double resulttwo;
double resultthree;
double resultfour;
double resultfive;

resultone = a + b;
resulttwo = a + c;
resultthree = a * c;
resultfour = b / c;
resultfive = b % a;

lala(resultone);
lala(resulttwo);
lala(resultthree);
lala(resultfour);
lala(resultfive);
}

public static void lala(double output) {
result++;
System.out.println("result " + result + " is " + output);
}

public static void lol() {
while(counter < 10){
counter++;
int number = 0;
number++;
System.out.println("Counter "+ number + " is " + counter);
}
}
}

最佳答案

i want to also get the lol method text

如果你想让它输出 10 行

public static void  lol() {
for (int i = 0; i < 10; i++) {
counter++;
System.out.println("Counter "+ i + " is " + counter);
}
}

下一步添加:

public static void main(String[] args) {
lol();

关于java - 我做了一个初学java "math"但不知道错误在哪里,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14164442/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com