Note that there are some explanatory texts on larger screens.

plurals
  1. POJava calculator using scanner but no out put displayed in console
    primarykey
    data
    text
    <p>I am learning Java and just been working on creating a little calculator. I am writing one what will allow me to put any number of digits in until I press an equals sign at which point I want the calculator to display the total.</p> <p>I think that there is a problem with the scanner as while debugging I only get as far as <code>Scanner input = new Scanner (System.in):</code> In the debugger it say Source not found. This is really strange especially as I am using two Scanners the other class within the same project with no problems at all. As you can tell I used to have 2 scanners in this piece but I read that this should not work so I am now using one. Here is the code...</p> <pre><code>package Calculator; import java.util.Scanner; public class Calculator3 { public static void main(String[] args) { Scanner input = new Scanner (System.in); // Scanner opin = new Scanner (System.in); String operative = input.next(); double numb = input.nextDouble(); int answer = 0; int calc = 1; System.out.print("#######################################" + "\n"); while (operative.equalsIgnoreCase("=")) { System.out.print("Interger " + calc + " :"); System.out.print("Type your Operative :"); if (operative.equals("+")) answer += numb; { if (operative.equals("-")) answer -= numb; { if (operative.equals("/")) answer /= numb; { if (operative.equals("*")) answer *= numb; { } } } } calc += 1; } System.out.print("#######################################" + "\n"); System.out.println("Your answer is: " + answer + "."); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload