answersLogoWhite

0


Best Answer

// Addition program that displays the sum of two numbers.

import java.util.Scanner; // program uses class Scanner

public class Addition

{

// main method begins execution of Java application

public static void main( String args[] )

{

// create Scanner to obtain input from command window

Scanner input = new Scanner( System.in );

int number1; // first number to add

int number2; // second number to add

int sum; // sum of number1 and number2

System.out.print( "Enter first integer: " ); // prompt

number1 = input.nextInt(); // read first number from user

System.out.print( "Enter second integer: " ); // prompt

number2 = input.nextInt(); // read second number from user

sum = number1 + number2; // add numbers

System.out.printf( "Sum is %d\n", sum ); // display sum

} // end method main

} // end class Addition

User Avatar

Wiki User

15y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

11y ago

//Program to check whether the given no is special or not

import java.io.*;

Public class special

{

Public static void main(String arg[]) throws IO Exception

{

InputstreamReader read=new Input Stream Reader(system.in)

BufferReader input=new BufferReader(rtead0:

System.out.println("Entrer the special no")

String X=input.read Line();

int n=Integer.parseInt(x):

int sum=0,f=1,d=0,num=n;

for(;n>o;)//(n!=0)

{

d=n%10;

for(int i=1;i<=d;i++)

{

f=f*i

}

sum=sum+f;

f=1;

n=n/10;

}

if(sum==num)

System.out.println("It is a special no")

else

System.out.println("It is not a special no");

}

}

This answer is:
User Avatar

User Avatar

Wiki User

14y ago

In Java applications, use the Scanner class. For instance:

import java.util.scanner;

...

Scanner input = new Scanner(System.in);

System.out.println("Type a word: ");

String word = input.nextLine();

Oh, and by the way, the Scanner class didn't exist until jdk 1.5.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How do you How do you write the special number program in java?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Can we add website link when we write java program?

yes ,i can add the website link in java program when we write.


How do you write a java program to find the square root of a number?

You can use the Math.sqrt() method.


Write a c program Fibonacci series using for loop in java?

Exactly what do you mean by 'C program in Java'


What is javadoc?

write a java program to display "Welcome Java" and list its execution steps.


How write new line program in java?

\n


How do you write a program using function that counts the number of vowels in a string in java language?

Use text-editor notepad++


Write a statementin a java program to read 2 integers and dispay the number of interagers between them?

a=153 a=n%10;


How do you write a java program for finding multiligual languages?

You can use Java's built-in functions to write a code that will find multilingual languages.


How java is 100 percent Internet based?

It isn't. It can also be used to write desktop applications. Java does have many options to program for the Internet, but that is not the only possibility.It isn't. It can also be used to write desktop applications. Java does have many options to program for the Internet, but that is not the only possibility.It isn't. It can also be used to write desktop applications. Java does have many options to program for the Internet, but that is not the only possibility.It isn't. It can also be used to write desktop applications. Java does have many options to program for the Internet, but that is not the only possibility.


Write a java code to draw a circle inside in an ellipse?

write a program draw circle and ellipse by using oval methods in java


Write a java program to display the number is prime or not?

Simply use a for loop (i) that runs from 2 to N-1. Checking if N % i 0 then its a prime number.


How do you write a java program to find the ad joint of a matrix?

bgfygfrhjyuyhh