Instead of println(String)
before each input, change it to print(String)
. So it would look something like this:
public class question3{
public static void main(String[] args){
Scanner s = new Scanner(System.in);
System.out.print("Enter the first number:");
Float a = s.nextFloat();
System.out.print("Enter the second number:");
Float b = s.nextFloat();
System.out.println("Sum = " + (a+b));
System.out.println("Difference = " + (a-b));
System.out.println("Product = " + (a*b));
}
}
Also, just a note, you should use proper/appropriate naming conventions for your variables. Like for your Scanner
, you should call it reader
or input
; something which represents its function. The same idea goes for the rest of your variables. Also, class names start with a capital.
Here is what the finished result looks like: