How to prompt user

How to prompt user

Dear Sir,

I'm a new student, a beginner in Java. Pls help to write program as below :-

a)to prompt user to input 2 integers, the 1st number entered as Digit 1 and 2nd number as Digit 2. b)Display the value of Digit 1 and Digit 2, indicating which is 1st & which is 2nd number. c)Multiply the value of Digit 1 by 2, sum the value of Digit 2 to it and store the result as Digit 3. Display the value of "Digit 3".

Tks & Rgds, KC

View Answers

August 9, 2011 at 10:42 AM

import java.util.*;
class NumberExample{
    public static void main(String[] args) throws Exception{
        Scanner input=new Scanner(System.in);
        int sum=0;
        System.out.println("Enter number1: ");
        int digit1=input.nextInt();

        System.out.println("Enter number2: ");
        int digit2=input.nextInt();

        System.out.println("First digit is: "+digit1+" and second digit is: "+digit2);
        int digit3=(digit1*2)+digit2;
        System.out.println("Result is: "+digit3);

    }
}









Related Tutorials/Questions & Answers:
How to prompt user
How to prompt user  Dear Sir, I'm a new student, a beginner in Java. Pls help to write program as below :- a)to prompt user to input 2 integers, the 1st number entered as Digit 1 and 2nd number as Digit 2. b)Display the value
Excel Prompt User on Focus
Excel Prompt User on Focus In this section, you will learn how to prompt user... will learn how to prompt user on focusing the cell. Here, the message title and message is user defined. import java.io.FileNotFoundException; import
Advertisements
Prompt
Prompt  I have a program that is asking for user input. It is divided into methods in the method asking for the input it uses a prompt command...) { System.out.print(**prompt** + ' '); return numberOfGrades } I don't undersant
prompt using
prompt using  I want examples to use prompt and how to move the item from the prompt to a cell in a table. thank you
using prompt
using prompt  how to use prompt
Java get User Input
Java get User Input       In this section, you will learn how to get the user input from... prompt the user to enter the name by using System.out.print() method to keep
How to connect to MySQL from command prompt?
How to connect to MySQL from command prompt? This video tutorial walks you... tutorial of: "How to connect to MySQL from command prompt?"ADS... learned How to connect to MySQL database from command prompt. Check all
How to check if ZooKeeper is running or up from command prompt
How to check if ZooKeeper is running or up from command prompt  Hi, I want to see if the ZooKeeper is running or not on my Hadoop cluster. How to check if ZooKeeper is running or up from command prompt? Thanks   Hi
ModuleNotFoundError: No module named 'prompt'
'prompt' How to remove the ModuleNotFoundError: No module named 'prompt'...ModuleNotFoundError: No module named 'prompt'  Hi, My Python... to install padas library. You can install prompt python with following command
javascript for prompt - JSP-Servlet
javascript for prompt  Dear sir, I have used prompt() for taking a reason while deleting using java script its working fine but prompt was coming at the top left so i want that prompt should come at middle so how to do
javascript for prompt - JSP-Servlet
then that prompt was not coming..So please tel me how to validate a prompt...javascript for prompt  Dear Sir, I am using a prompt() for taking... a prompt contains any special character or what.If contains a alert message has
What is a prompt box?
What is a prompt box?  What is a prompt box
How to read user input in C++
How to read user input in C++  How can i get an input from the users in C++?   You can use the standard input "cin" to get the input from user.. For example: int age; cin >> age
javascript for prompt - JSP-Servlet
an object ,so how to remove this script error.And also this prompt is coming...javascript for prompt  Dear sir, I am using prompt()for taking a reason from vendor . var reason=prompt('Reason for deleting:',''); Then i
Video Tutorial: How to create a database in MySQL using Command prompt?
How to create a database in MySQL using Command prompt MySQL is an Operation... is the video tutorial of "How to create database in MySQL using command prompt?": ADS_TO_REPLACE_1 In this tutorial we will learn how to create a database
ModuleNotFoundError: No module named 'dob-prompt'
'dob-prompt' How to remove the ModuleNotFoundError: No module named 'dob-prompt' error? Thanks   Hi, In your python environment you...ModuleNotFoundError: No module named 'dob-prompt'  Hi, My Python
ModuleNotFoundError: No module named 'hyper-prompt'
'hyper-prompt' How to remove the ModuleNotFoundError: No module named 'hyper-prompt' error? Thanks   Hi, In your python...ModuleNotFoundError: No module named 'hyper-prompt'  Hi, My Python
ModuleNotFoundError: No module named 'prompt-box'
'prompt-box' How to remove the ModuleNotFoundError: No module named 'prompt-box' error? Thanks   Hi, In your python environment you...ModuleNotFoundError: No module named 'prompt-box'  Hi, My Python
ModuleNotFoundError: No module named 'prompt-for-password'
named 'prompt-for-password' How to remove the ModuleNotFoundError: No module named 'prompt-for-password' error? Thanks   Hi...ModuleNotFoundError: No module named 'prompt-for-password'  Hi, My
ModuleNotFoundError: No module named 'prompt-toolkit'
named 'prompt-toolkit' How to remove the ModuleNotFoundError: No module named 'prompt-toolkit' error? Thanks   Hi, In your python...ModuleNotFoundError: No module named 'prompt-toolkit'  Hi, My
ModuleNotFoundError: No module named 'pv-prompt'
-prompt' How to remove the ModuleNotFoundError: No module named 'pv-prompt' error? Thanks   Hi, In your python environment you...ModuleNotFoundError: No module named 'pv-prompt'  Hi, My Python
ModuleNotFoundError: No module named 'pv-prompt'
-prompt' How to remove the ModuleNotFoundError: No module named 'pv-prompt' error? Thanks   Hi, In your python environment you...ModuleNotFoundError: No module named 'pv-prompt'  Hi, My Python
ModuleNotFoundError: No module named 'sphinx-prompt'
'sphinx-prompt' How to remove the ModuleNotFoundError: No module named 'sphinx-prompt' error? Thanks   Hi, In your python...ModuleNotFoundError: No module named 'sphinx-prompt'  Hi, My
ModuleNotFoundError: No module named 'sphinx-prompt'
'sphinx-prompt' How to remove the ModuleNotFoundError: No module named 'sphinx-prompt' error? Thanks   Hi, In your python...ModuleNotFoundError: No module named 'sphinx-prompt'  Hi, My
ModuleNotFoundError: No module named 'argparse-prompt'
named 'argparse-prompt' How to remove the ModuleNotFoundError: No module named 'argparse-prompt' error? Thanks   Hi, In your python...ModuleNotFoundError: No module named 'argparse-prompt'  Hi, My
ModuleNotFoundError: No module named 'dob-prompt'
'dob-prompt' How to remove the ModuleNotFoundError: No module named 'dob-prompt' error? Thanks   Hi, In your python environment you...ModuleNotFoundError: No module named 'dob-prompt'  Hi, My Python
ModuleNotFoundError: No module named 'http-prompt'
'http-prompt' How to remove the ModuleNotFoundError: No module named 'http-prompt' error? Thanks   Hi, In your python environment...ModuleNotFoundError: No module named 'http-prompt'  Hi, My Python
ModuleNotFoundError: No module named 'hyper-prompt'
'hyper-prompt' How to remove the ModuleNotFoundError: No module named 'hyper-prompt' error? Thanks   Hi, In your python...ModuleNotFoundError: No module named 'hyper-prompt'  Hi, My Python
ModuleNotFoundError: No module named 'influx-prompt'
'influx-prompt' How to remove the ModuleNotFoundError: No module named 'influx-prompt' error? Thanks   Hi, In your python...ModuleNotFoundError: No module named 'influx-prompt'  Hi, My
javascript prompt alert
javascript prompt alert   Sending a prompt alert using a JavaScript function
how to find which user has modified the file
how to find which user has modified the file  how to find which user has modified the file
how to create a user registration form in php
how to create a user registration form in php  how to create a user registration form in php
What is command prompt in Java?
What is command prompt in Java?  Hi, What is command prompt in Java? Thanks   Hi, On the Windows Command Prompt is a program to run the dos commands. This prompt is used to run any program by typing the name
Command Prompt in UI
Command Prompt in UI  Hi, Is there any API or JAR file for running all the windows command prompt commands like dir,echo,ping commands? If any please tell me what is it? Thanks & Regards---Vanchinathan.R
command prompt is compilation is not working
command prompt is compilation is not working   Dear java users can anyone help me to run the program in command line prompt i tried by selecting... helloworld through command prompt class not found error and class loader not able
How to get a list of MySQL user accounts?
How to get a list of MySQL user accounts?  Hi, I have MySQL database... of all the users. How to get a list of MySQL user accounts? Thanks   Hi, In MySQL users information is stored in user table of mysql datababse
How to get a list of MySQL user accounts?
How to get a list of MySQL user accounts?  Hi, I have MySQL database... of all the users. How to get a list of MySQL user accounts? Thanks   Hi, In MySQL users information is stored in user table of mysql datababse
Command Prompt in UI
Command Prompt in UI  Hi One Help... Please go through. I want to develop like that using jsp/javascript but nothing is striking in mind... Please give some suggestions to design first Thanks in advance---- Vanchinathan.R
ModuleNotFoundError: No module named 'django-prompt-responses'
: No module named 'django-prompt-responses' How to remove the ModuleNotFoundError: No module named 'django-prompt-responses' error? Thanks   ...ModuleNotFoundError: No module named 'django-prompt-responses'  Hi
ModuleNotFoundError: No module named 'ipython-venv-path-prompt'
: No module named 'ipython-venv-path-prompt' How to remove the ModuleNotFoundError: No module named 'ipython-venv-path-prompt' error? Thanks  ...ModuleNotFoundError: No module named 'ipython-venv-path-prompt'  Hi
ModuleNotFoundError: No module named 'prompt-tr-free'
named 'prompt-tr-free' How to remove the ModuleNotFoundError: No module named 'prompt-tr-free' error? Thanks   Hi, In your python...ModuleNotFoundError: No module named 'prompt-tr-free'  Hi, My
ModuleNotFoundError: No module named 'xontrib-prompt-ret-code'
: No module named 'xontrib-prompt-ret-code' How to remove the ModuleNotFoundError: No module named 'xontrib-prompt-ret-code' error? Thanks   ...ModuleNotFoundError: No module named 'xontrib-prompt-ret-code'  Hi
ModuleNotFoundError: No module named 'ipython-venv-path-prompt'
: No module named 'ipython-venv-path-prompt' How to remove the ModuleNotFoundError: No module named 'ipython-venv-path-prompt' error? Thanks  ...ModuleNotFoundError: No module named 'ipython-venv-path-prompt'  Hi
ModuleNotFoundError: No module named 'prompt-tool-kit'
named 'prompt-tool-kit' How to remove the ModuleNotFoundError: No module named 'prompt-tool-kit' error? Thanks   Hi, In your python...ModuleNotFoundError: No module named 'prompt-tool-kit'  Hi, My
ModuleNotFoundError: No module named 'prompt-toolkit-menu'
named 'prompt-toolkit-menu' How to remove the ModuleNotFoundError: No module named 'prompt-toolkit-menu' error? Thanks   Hi...ModuleNotFoundError: No module named 'prompt-toolkit-menu'  Hi, My
ModuleNotFoundError: No module named 'xontrib-repa-prompt'
named 'xontrib-repa-prompt' How to remove the ModuleNotFoundError: No module named 'xontrib-repa-prompt' error? Thanks   Hi...ModuleNotFoundError: No module named 'xontrib-repa-prompt'  Hi, My
ModuleNotFoundError: No module named 'xontrib-prompt-vi-mode'
: No module named 'xontrib-prompt-vi-mode' How to remove the ModuleNotFoundError: No module named 'xontrib-prompt-vi-mode' error? Thanks   Hi...ModuleNotFoundError: No module named 'xontrib-prompt-vi-mode'  Hi
ModuleNotFoundError: No module named 'xontrib-repa-prompt'
named 'xontrib-repa-prompt' How to remove the ModuleNotFoundError: No module named 'xontrib-repa-prompt' error? Thanks   Hi...ModuleNotFoundError: No module named 'xontrib-repa-prompt'  Hi, My
ModuleNotFoundError: No module named 'django-prompt-responses'
: No module named 'django-prompt-responses' How to remove the ModuleNotFoundError: No module named 'django-prompt-responses' error? Thanks   ...ModuleNotFoundError: No module named 'django-prompt-responses'  Hi
how to send smtp mail to entered user mail id after user registered using javascript?
how to send smtp mail to entered user mail id after user registered using javascript?  how to send smtp mail to entered user mail id after user registered using javascript

Ads