I added a Breakpoint here:

public class JavaApplication8 {

I added another here:

public static void main(String[] args) {

Finally, I added one more here:

Scanner input = new Scanner(System.in);

Ctrl + F5 is supposed to start the debugger, right. Mine doesn't work. When I hit Ctrl+F5, another window opens and it's called 'Class.java'. If I just try to run the code by hitting F6, the code simply runs and none of the break points are hit. This is so weird. I've never seen anything like it. Does anyone have any idea what could be wrong here?

Here is my code.

package javaapplication8;

import java.util.Scanner;

public class JavaApplication8 {

    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        System.out.println("Celsius of your input is Fahrenheit degree ");
        double myinput = input.nextInt();
        System.out.println(myinput + 32 * (9/5));
    }

}

I want to debug this, so I can learn how the debugger works. Also there really is something wrong with this code. It just adds 32 to whatever number I enter. The 9/5 is never hit, which is very weird.

What happens when you do the following?

System.out.println(9/5);

You get 1.
32 x 1 = 32.

What you need to do is:

System.out.println(9.0/5.0);

You get 1.8.

When debugging computations that aren't working out, you can put the values into variables, print them out, do your computation and then print out the result.

So rather than doing:

System.out.println(myinput + 32 * (9/5));

In your original code, try the following:

Scanner input = new Scanner(System.in);
System.out.println("Celsius of your input is Fahrenheit degree ");
double myinput = input.nextInt();

double nineFifths = 9 / 5;

System.out.println(nineFifths);

System.out.println(myinput);

System.out.println(myinput + 32);
System.out.println (myinput + 32 * nineFifths);

This will help you figure out where your problems are.

Additionally, you have other problems. Hint: check your formula again. And then consider order of operations.

I want to debug this, so I can learn how the debugger works.

"The debugger"

You might want to specify what IDE you are using next time, there's not just one "debugger". For NetBeans it should be ctrl+F5 yes, perhaps try one of the other ways.

Sorry, I should have mentioned it in my original email.
I'm using NetBeans IDE 8.0.2.

If I hit Ctrl+F5, a window named 'Class.java' opens, and then I don't understand what happens. If I hit F8 over and over, the focus stays in the 'Class.java' window. It's the same if I hit F7 repeatedly. If I hit F6, the code runs, but I still can't debug it. I don't think anything happens if I hit F5.

With focus in the Netbeans editor window showing your main class, CtrlF5 (cmd/shift/F5 on OSX) shoud bring up the Output window with 2 tabs (the normal system output window + the debug console).
What exactly is the sequence of states/events that you are using, and what exactly do you see?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.