Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6619413
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:57:51+00:00 2026-05-25T20:57:51+00:00

I am trying to create a simple calculator in the console for single digit

  • 0

I am trying to create a simple calculator in the console for single digit numbers.(Well I actually only care about multiplication)

So, here is my code and if someone could help me.

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();

    }    
}

I added comments to explain what I was doing to everyone else, and just as personal notes.

The last line always ends up as “(0) times 13 equals 0.” -Assuming I used zero for input 1.

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.

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T20:57:51+00:00Added an answer on May 25, 2026 at 8:57 pm

    The problem is that you are reading two characters one after the other. input is set when you press the 1 key. input1 is read when you press the Enter key. Just don’t press the Enter key; instead enter both numbers immediately one after the other. The best way to solve this is System.Console.ReadLine

    System.Console.Read reads a single character from the console. When you type the 0 key, your program actually reads the character ‘0’ (‘0’ == 48 in ASCII) not the number 0.

    Here’s how I would fix your program:

    Instead of using System.Console.Read, which reads a character, I would use System.Console.ReadLine which reads an entire line rather than a single key/character. This would allow your users to enter numbers longer than one digit. You can convert the user’s input from a string to an integer by using Int32.Parse

    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 = Int32.Parse(System.Console.Read());
    
        //input = input - 48;//No need to do this anymore as we have already converted the user's input to an integer.
    
        System.Console.WriteLine();
    
        System.Console.Write("Please enter the second number: ");
        input1 = Int32.Parse(System.Console.ReadLine());
        System.Console.WriteLine();
    
        output = input * input1;
    
        System.Console.WriteLine();
        System.Console.Write("{0} times {1} equals {2}.", input, input1, output);
    
        System.Console.ReadKey();
    
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In this program I am trying to create a simple calculator. However, I can't
Im trying to to create a simple 4 function calculator using a jump table
I am trying create a simple WQL query where I only return mounted drives
I'm trying to create simple 2D action game, something similar to well known Fancy
I have been trying to create a simple calculator. Using PHP I managed to
I'm trying to create simple DER decoder - console application that just outputs content
Im trying to create a simple pan and zoom app using silverlight 4, but
I am trying to create a simple dialog in MFC using Visual C++. My
I am trying to create a simple page that enters data in to a
I'm trying to create a simple BaSH-like grammar on ANTLRv3 but haven't been able

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.