-3

(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
    Welcome to Stack Overflow! Relevant code and error messages need to be included in your question *as text*, [not as pictures of text](https://meta.stackoverflow.com/q/285551/328193). Just linking to screen shots makes it more difficult for people to help you. To learn more about this community and how we can help you, please start with the [tour] and read [ask] and its linked resources. – David Jun 14 '23 at 17:58
  • 1
    Additionally... This is a good opportunity for you to start familiarizing yourself with [using a debugger](https://stackoverflow.com/q/25385173/328193). When you step through the code in a debugger, which operation first produces an unexpected result? What were the values used in that operation? What was the result? What result was expected? Why? – David Jun 14 '23 at 17:58

1 Answers1

1

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

ob.a = sc.nextDouble();
ob.b = sc.nextDouble();
Reilas
  • 3,297
  • 2
  • 4
  • 17