There is no syntax error in this program, but the values aren't coming as intended…..How can I make this program run?

huangapple go评论72阅读模式
英文:

There is no syntax error in this program, but the values aren't coming as intended.....How can I make this program run?

问题

I'm a newbie to Java, and haven't completed learned it yet. Still, I'm trying my best to solve as many problems as possible and get better.

So my query is, how can this program be fixed ??

The output is something like (https://i.stack.imgur.com/c4qCn.jpg)

Someone please correct this program, without removing the Scanner class.

I really tried to make this program run, but it just wasn't working. The values were always 0 or 0.0, no matter what I did....

Can someone also explain what went wrong here ??

Thank you in advance.🤗🤗

英文:

(https://i.stack.imgur.com/kDec2.jpg)

I'm a newbie to Java, and haven't completed learned it yet. Still, I'm trying my best to solve as many problems as possible and get better.

So my query is, how can this program be fixed ??

The output is something like (https://i.stack.imgur.com/c4qCn.jpg)

Someone please correct this program, without removing the Scanner class.

I really tried to make this program run, but it just wasn't working. The values were always 0 or 0.0, no matter what I did....

Can someone also explain what went wrong here ??

Thank you in advance.🤗🤗

答案1

得分: 1

你需要使用_ob_实例来访问_a_和_b_。

ob.a = sc.nextDouble();
ob.b = sc.nextDouble();
英文:

You'll need to use the ob instance to access a and b.

ob.a = sc.nextDouble();
ob.b = sc.nextDouble();

huangapple
  • 本文由 发表于 2023年6月15日 01:56:14
  • 转载请务必保留本文链接:https://go.coder-hub.com/76476344.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定