Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners How to prompt user

Have Programming Question? Ask it here!
 
 
 


Sau Kee Chuan
How to prompt user
1 Answer(s)      2 years and 11 months ago
Posted in : Java Beginners


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


Advertisement
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
using prompt
using prompt  how to use prompt
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
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
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
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
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 prompt alert
javascript prompt alert   Sending a prompt alert using a JavaScript function
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
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
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
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 save user interface in flex for design tool
How to save user interface in flex for design tool  Hi I want to create a flex application "sticker design tool" in which i want to save all... user want to re-customize it later on then he can able to re-customize it. please
how to import user-define package to applet - Applet
how to import user-define package to applet  how to import user-define package to applet... can u write a java coding can execute in jdk only .... thx...  Hi friend, import java.applet.*; import java.util.
How to hide HTML code from user? - Security
How to hide HTML code from user?  Hi All, I am trying to provide security to my web application. To achieve this I want to restrict user from viewing HTML source code. Can any one guide me for this topic? Thanks
Prompt for a password when deleting a data
Prompt for a password when deleting a data  I am using netbeans and mysql. i have added a username and password. i have a set of data in the database. so when deleting a data it should prompt for the password and if the password
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
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
how can i send a mail to a particular user from a many user dropdown list in jsp
how can i send a mail to a particular user from a many user dropdown list in jsp  how can i a sent a user question to a particular person from a drop down list in jsp
how can I great two user and password in C++?
how can I great two user and password in C++?  how can I great two user and password in c
how can I great two user and password in C++?
how can I great two user and password in C++?  how can I great two user and password in C
how to prevent user selecting past date from calender
how to prevent user selecting past date from calender  how to prevent user selecting past date from calender ex: today's date is 21st march user should not select 20th march or below
how to create a new table for the already existing user in the website
how to create a new table for the already existing user in the website  haiii....i want the code in jsp "how to create a new database for every user that has been already existing in the website?"....plzzzz help me
How to insert image in sql database from user using servlet
How to insert image in sql database from user using servlet  pls tell me accept image from user and insert image in sql server 2005 database using servlet and jsp
javascript for textbox or prompt using servlet - JSP-Servlet
javascript for textbox or prompt using servlet  Dear sir, I am using a prompt(),when a delete is confirmed,its working fine ,but when a prompt is closed or cancel ,i have to remain in the same page but here it is going
javascript for textbox or prompt using servlet - JSP-Servlet
javascript for textbox or prompt using servlet  Dear sir I am writing script in servlet,so prompt() is not working here so please help me... how to do in servlet.please help me.. My code is as follows out.println
run command prompt from jsp program
run command prompt from jsp program  Hi.... Is it possible to run a command prompt from jsp? If possible please help me with some code... Thanks & Regards vanchinathan.R
how to retreive data from database of a particular user after login
how to retreive data from database of a particular user after login  ... my question is how to retrieve this information of user after registration... the user information.. now their is a login and registration page for newuser
how to make two types of user for a web dynamic project
how to make two types of user for a web dynamic project  Hello... everything in project..can someone help me regarding this. how to make two types of user... is that i want to make two user one is admin other is genral user, the admin can see all
How to find out the friend user between two columns in sql database
How to find out the friend user between two columns in sql database  Hi, Can any one please tell me ..how to find out the friend user between two columns in sql database? In other words i wanted to get the corresponding data from
how to retreive data from database of a particular user after login
how to retreive data from database of a particular user after login  sir am doing project in ASP.NET useful for my college that is placement portal... to display the details of only current user who logged
How to take input by user using jDialogue and use that input
How to take input by user using jDialogue and use that input  I am using NetBeans i have a 'Search by employee id' button . I want when user click this button a dialogue box appear which take employee_id as input from user
How to view database for user when they login in netbeans and mysql?
How to view database for user when they login in netbeans and mysql?  I create a web page where when user login they have to fill in a form, after... but it come out with all the other user information too. I'm using netbeans and mysql
how to send sms from my website to mobile of particular user.
how to send sms from my website to mobile of particular user.  i had created a website and aim of pjt is whoever the client register for site..... so can u tell the process and how to implemnt this using java
How to compile PHP file and provide it to user without code?
How to compile PHP file and provide it to user without code?  I have... in asp.net instead of providing code file. How can I compile the PHP file and provide it to my user in the form dll or may be with other type or extension? Please
How to create file and save it into user defined path using jsp/servlet?
How to create file and save it into user defined path using jsp/servlet?  Hi.. Onclick event I have created one file.When file will create it should asked where to save file(like browse option
how to make authentication for each user using jsp/servlet?
how to make authentication for each user using jsp/servlet?  i have 10 jsp pages and 5 users.I use 10 buttons for open the page.Admin assign some jsp pages to each user.If admin assign page1 and page2 for user1 then make other
How to store data entered by User in JSP page in XML file
How to store data entered by User in JSP page in XML file  How to store data entered by user in JSP page to be saved in XML file.On clicking submit button data entered by a user in a page must be saved in XML file.How to do so
How can I output text typed in textarea by user on the same page?
How can I output text typed in textarea by user on the same page?  I have a basic HTML page where I have created a textarea for users comments. I would like to take the comments and append them to the same page for all to see
How to Create a Different User Account in Windows 8?
in creating a user account, here you are. In this windows 8 tutorial, we will discuss How to create a different user account in Windows 8? Once you install...;         2. Now click to 'Add User' below
MySql Alter User
MySql Alter User This example illustrates how to alter user table. In this example we alter user table in which add a column by query "ALTER TABLE user... column. Query CREATE USER 'user'@'localhost' IDENTIFIED BY '1234556978
How to store user name,city,state,image path into database and image into folder using jsp
How to store user name,city,state,image path into database and image into folder using jsp  How to store user name,city,state,image path into database and image into folder using jsp
User Registration Form Using JSP(JspBeans) after that how i can insert in database
User Registration Form Using JSP(JspBeans) after that how i can insert in database   User Registration Form Using JSP(JspBeans) after that how i can insert in database
ask user how many numbers to be inputted and determine the sum and highest number using an array in java
ask user how many numbers to be inputted and determine the sum and highest number using an array in java  ask user how many numbers to be inputted and determine the sum and highest number using an array in java
Java get User Home
Java get User Home       In this section, you will study how to get the user home. We...("user.home")- This method retrieve the user's home directory
 

 

 

DMCA.com