Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2013
    Posts
    5
    Rep Power
    0

    Default How to Accept Input from the End User?

    Hello, I am a new programmer, and I have some questions:

    I have recently tried creating a "Java Calculator" but I have no idea how to accept user input and write that input to a variable. Here is my code so far:
    Java Code:
    package calculator;
    
    import java.util.*;
    
    public class Calculator {
        
        public static void main(String[] args) {
            System.out.println("Welcome to Java Calculator!");
            System.out.println("Enter the number corresponding to the type of math you would like to solve.");
            System.out.println("1 = Add | 2 = Subtract | 3 = Multiply | 4 = Divide");
        }
    }
    If any of you are familiar with Lua, I am trying to say "What is the Java equivalent of <variable> = io.read() and how do I apply it?"

    Thanks in advance!

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: How to Accept Input from the End User?

    Look up use of a Java Scanner object. It's full class name is java.util.Scanner.

  3. #3
    Join Date
    Jun 2013
    Posts
    5
    Rep Power
    0

    Default Re: How to Accept Input from the End User?

    Quote Originally Posted by Fubarable View Post
    Look up use of a Java Scanner object. It's full class name is java.util.Scanner.
    Thanks, I figured it out. :D

Similar Threads

  1. Program that must accept input redirection
    By static_rage in forum New To Java
    Replies: 1
    Last Post: 10-11-2012, 03:13 PM
  2. Security alert doesn't accept user input?
    By DLpres in forum New To Java
    Replies: 4
    Last Post: 02-03-2012, 07:57 AM
  3. Help with user input
    By sconniegorilla in forum New To Java
    Replies: 2
    Last Post: 02-16-2011, 03:00 PM
  4. Replies: 1
    Last Post: 09-24-2010, 08:08 PM
  5. How to accept operator from user in jdbc ?
    By senidaljeet in forum JDBC
    Replies: 5
    Last Post: 05-13-2010, 09:59 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •