System.out.print() not working

When I use System.out.print() the console doesn’t show anything, it only works if I put System.out.println() . Is there something I’m doing wrong?

import java.util.Scanner;

public class Calculator {
    
    public static void main(String[] args) {
    
        Scanner scanner = new Scanner(System.in);

        System.out.print("Principal : ");
        int principal = scanner.nextInt();
       
        System.out.print("Annual Interest Rate: ");
        float aInterestR = scanner.nextFloat();
        
        System.out.print("Period (Years): ");
        byte period = scanner.nextByte();
        
        double mortgage = principal * ((aInterestR*(1+aInterestR) * period)/(1+aInterestR)* period-1);
        

    
    
    }
    
    
    
}

Capture

The program worked well on my machine. However, in your code, the final mortgate didn’t show. You should print it.

And a quick reminder, you should use an “int” or “long” to store any non-technical integer value and “double” for any non-technical decimal value, even it is far less likely to exceed the limit. Bytes, Shorts, Floats are built for talking to your hardware.

Hi,
Yes you didn’t calculate the period and your mortgage formula is not correct.
Watch the solution or download the source file to see the code mosh used to calculate the mortgage

That looks like a glitch that I had with IntelliJ
Are you using IntelliJ?
Have you restarted the program?

When I had this issue, it would not use print(), but would use println().
It also wouldn’t print Strings > it would only print the reference to the memory.
Mine required a restart and resolved both issues.