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);
}
}
Ads
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
How to connect to MySQL from command prompt?
How to connect to MySQL from command
prompt?
This video tutorial walks you through the steps to connect to MySQL from command
prompt in Windows machine... of: "
How to connect to MySQL from command
prompt?"
Then is sure
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
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
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
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
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
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 '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 '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
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