Note that there are some explanatory texts on larger screens.

plurals
  1. POWhat am I doing wrong? /noob ?Learning to program
    primarykey
    data
    text
    <p>I am trying to create a simple calculator in the console for single digit numbers.(Well I actually only care about multiplication)</p> <p>So, here is my code and if someone could help me.</p> <pre><code>class multiplythisnumber { static void Main() { int input, input1, output; //variable decleration System.Console.WriteLine("This application is meant to multiply two single digit numbers."); System.Console.WriteLine("You can choose both numbers, however this is only a test.\r I am not sure the read command even does what I think it does."); System.Console.WriteLine(); System.Console.Write("Please enter the first number: "); input = System.Console.Read(); //Reads my input + 48(assuming 48 is the value of enter) input = input - 48; System.Console.WriteLine(); System.Console.Write("Please enter the second number: "); input1 = System.Console.Read(); //Doesn't wasit for input and sets input1 = 13 System.Console.WriteLine(); output = input * input1; System.Console.WriteLine(); System.Console.Write("{0} times {1} equals {2}.", input, input1, output); System.Console.ReadKey(); } } </code></pre> <p>I added comments to explain what I was doing to everyone else, and just as personal notes. </p> <p>The last line always ends up as "(0) times 13 equals 0." -Assuming I used zero for input 1.</p> <p>Edit: Just to clarify I know 0*13=0 (yes it said 12 earlier what it has really been saying is 13). The problem is that it is not allowing me to set input1 and is just setting it at 13 and continuing executing.</p> <p>Edit2: I would like to say thanks to Matt, because the changes he made allowed the code to work correctly. So, looks like I have my first code that actually does something other than tell you your own name.</p>
    singulars
    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.
 

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