Home Answers Viewqa Java-Beginners reads an integer from the user and determines whether it is odd or even

 
 


langat
reads an integer from the user and determines whether it is odd or even
2 Answer(s)      5 years and 2 months ago
Posted in : Java Beginners

reads an integer from the user and determines whether it is odd or even

View Answers

April 1, 2008 at 3:42 PM


Hi
Here is the application for reads an integer from the user and determines whether it is odd or even


import java.io.*;
class Test
{
public static void main(String args[])throws IOException
{
//to read an integer from the user
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println("enter an interger");
int i=Integer.parseInt(br.readLine());
if(i%2==0)
System.out.println("the given no is an even number");
else
System.out.println("the given no is an odd number");
}
}



April 1, 2008 at 3:43 PM


Hi
Here is the application for reads an integer from the user and determines whether it is odd or even


import java.io.*;
class Test
{
public static void main(String args[])throws IOException
{
//to read an integer from the user
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println("enter an interger");
int i=Integer.parseInt(br.readLine());
if(i%2==0)
System.out.println("the given no is an even number");
else
System.out.println("the given no is an odd number");
}
}










Related Pages:
Check whether highest number is even or odd
Check whether highest number is even or odd In this section, you will learn how to check highest number between the two numbers and then determine whether it is odd or even. For this, we have taken two integer variables num1 and num2
odd and even
odd and even  how can i make a program of even and odd using case...{ System.out.println(); System.out.println("1 Display Even"); System.out.println("2 Display Odd"); System.out.println("3 Exit"); System.out.print("Choose
JSTL - check odd/even number - JSP-Servlet
JSTL - check odd/even number  How do i create a JSTL program to generate random numbers and to check whether they are odd/even and print "this is an even (odd) number and it is in between so and so number? e.g. the random number
Odd Even Transposition Sort In Java
In this example we are going to sort integer values of an array using odd even transposition sort. Odd even transposition sort is a parallel sorting algorithm. Odd Even... Odd Even Transposition Sort In Java   
Check Even-Odd:-Example
reads a integer value and check weather number is Odd or Even. In this example you will learn how to determine the Even or Odd for the given number entered... Check Even-Odd:-Example     
accept integer from user
accept integer from user  Write an Java application that accepts 100 integer numbers from a user. The input should be in the range of 1-200. Error message needs to be displayed if user entered input which is not in this range
Even and odd functions in java
Even and odd functions in java  Even and odd functions in java  ... have two separate functions for checking either number is even or odd. We...); int number; System.out.println("Input any number to check even
Check even or odd number.
Check even or odd number.  How to check given number is even or odd?   Simple if it is devided by 2 it is even and if not if is Odd  ...){ System.out.println("Number is Even"); } else
Calculate sum of even and odd numbers in Java
Calculate sum of even and odd numbers In this section, you will learn how to read the file that contains even and odd numbers and calculate their sum separately. To do this, first of all, we have found all the even and odd numbers from 1
Programming: Prime Numbers - Dialog
________________________________________ Description Write a program that reads an integer from the user, and displays a message about whether or not it's a prime number. Prime... or not is to try dividing it by all integers from 2 to n-1. If any of them can
Checking the decimal whether comma used or not
Checking the decimal whether comma used or not  I need to check the given integer whther comma used or not. For example. If the user given 123456 The output should be like 123,456 If the user given 123,456 The output should
java code - Java Beginners
reads an integer from the user and determines whether it is odd or even  reads an integer from the user and determines whether it is odd or even ...;Hi Here is the application for reads an integer from the user and determines
PRIME AND EVEN AND ODD - Java Interview Questions
PRIME AND EVEN AND ODD  how to write prime numbers?i want source code? how to write even numbers? i want source code? how to write odd numbers ?i... + " "; } } } System.out.println(primeNo); } } 2) Following code displays Even and Odd numbers
even more circles - Java Beginners
even more circles  Write an application that compares two circle objects. ? You need to include a new method equals(Circle c) in Circle class. The method compares the radiuses. ? The program reads two radiuses from the user
retreive integer data from database
retreive integer data from database  i made a table named result... and two buttons "ok" and "cancel" i want to take input from textfield as an integer(rollno) and the marks associated with that must be displayed.i write
Operator Precedence
precedence table. Precedence determines order of evaluation Mathematical... with it. The precedence determines which operations will be performed first... knows whether equal-precedence operators should be performed left-to-right
Integer exception in java
, if the user enter the number other than integer it will gives an exception error. if the user enters integer it will display the number which the user have... Integer exception in java   
to read number from user
to read number from user  1)print the positive equivalent of the number 2) check if the no is integer or not 3) find the square root of the number 4) find the cube of the number
Change the user input to integer
Change the user input to integer   ... an integer value after the compilation of a program and force the JVM to ask... that JVM reads each data type in a String format. Now consider a case where we
Write a function that reads a string of digits, possibly preceded by + or -, and converts this string to the integer value it represents.
Write a function that reads a string of digits, possibly preceded by + or -, and converts this string to the integer value it represents.  Write a function that reads a string of digits, possibly preceded by + or -, and converts
ask a user to enter 5 integer
ask a user to enter 5 integer  make a program that enter 5 numbers then identify the largest and the smallest number sample program 2 4 3 5 6 the smallest number: 2 the largest number: is 6 66
Java
Java  Write a program that repeatedly reads an integer from the console. If the integer is odd, outputs "Odd Day" if the integer is even (and not 0), outputs â??Even now". if the integer is 0. exits program
integer to string
integer to string  i have to develop a program which convert integer into character from 1 to 10,000 if we input 1 then it give output 'one' n so on till 'ten thousand' kindly give me the codes plzplz sir........   Have
help pleas? -_-
help pleas? -_-  Write a Java program that reads from the user an integer N followed by N integers. The program then prints the product of odd integers, and, the sum of even integers
Password Controls
determines whether the password entered by the user is correct or not. This whole process is controlled on the server side. Once the password is entered by the user it goes to the server and on the server side the controller checks whether
Factorial Program in Java
. System.in is used to take the input from system/user at run time. InputStreamReader reads the input from user and then keep it into a buffer. As Java reads... integer number. In the following example, a class by the name "Factorial1" is used
java program (integer/decimal) - Java Beginners
java program (integer/decimal)  Accept a number from the user as command line arguments. The number could be an integer or decimal value. ? Display the absolute value of the input number ? Display the rounded off value
print the sum of even number from 1 to 100
print the sum of even number from 1 to 100  how to print the sum of even number from 1 to 100 using for loops? Thanks
Calculator program in Java
a class "calculator" is used. System.in takes the input from the system/user at run time. InputStreamReader reads the input from System.in and then keep... into integers. If the user enters a "+" operator it will add the two integer numbers
Loops
Loops  Write a program that repeatedly reads an integer from the console. If the integer is odd, outputs ââ?¬Å?Odd Day!ââ?¬Â? if the integer is even (and not 0), outputs ââ?¬Å?Even now!ââ?¬Â?. if the integer is 0. exits
Leap Year Program
Java NotesLeap Year Program This program reads a year and tells the user if it's a leap year or not. It uses boolean operators instead... whether a give year is leap year or not. // Michael Maus, 22 Sept 2004 import
Check Whether Record is already Exists or Not with Database Connectivity - Java Beginners
Check Whether Record is already Exists or Not with Database Connectivity  Hello Sir I want Program to Check Whether ID is Already exists..."; String driver = "com.mysql.jdbc.Driver"; String user = "root"; String pass
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... through the use of DOM loading the data from another javascript file
How does this example work even if no oracle to be used and only access is available?
How does this example work even if no oracle to be used and only access... { try { UserBean user = new UserBean(); user.setUserName(request.getParameter("un")); user.setPassword(request.getParameter("pw")); user
get integer at run time
get integer at run time  how to get integer value at run time in j2ee using servlets   Hi, You can get the value from request parameter... is the example code: String s =request.getParameter("myvariable"); Integer i
Example - WordFrequency
Java Notes: Example - WordFrequency This program reads files of words... user interface The model (the logic of the program without any user interface...; } //=============================================================== ignoreFile /** Reads file of words to ignore. Ignore words
How to check whether database exists?
How to check whether database exists?  Hi, I have to create a database in mysql. I am able to create that successfully from using JDBC. But before to creating the database, i want to check whether database exists or not? How can
Mysql Mod
you use MOD(a, 3) you get 1 for even numbers and 0 for odd numbers. If you use... The Tutorial illustrate an example from Mysql Mod. To understand and grasp the example...: mysql> select * from oddeven; +------+------+ | a | b
Reverse integer array program
Reverse integer array program  Been tasked with the following question: Write a method that accepts an integer array and returns a new array...] the output array is [8, 6, 4, 2]. Then call your method from the main method
Checking whether a year is leap or not
Checking whether a year is leap or not   ... for checking whether a year is a leap year or not. Here, we have taken the year 2000. So define an integer n=2000 in the class "Leapyear" and now apply "
Check whether the number is palindrome or not
Check whether the number is palindrome or not A palindrome is a word, phrase, number or other sequence of units that can be read the same way in either direction. Here we are going to check whether the number entered by the user
Java get User Input
Java get User Input       In this section, you will learn how to get the user input from... input. The br.readline() method reads the name from the command line. After
how to search for string using LIKE operator instead of integer?
how to search for string using LIKE operator instead of integer?  ...". what my code does is goes to the "index.jsp" file and let the user enters an ID..., itemname, and description. the itemid is in hyperlink so when the user click
file share to particular user
_desc,up_date from files where user_id='"+i+"' "); while(rs.next()){String id...(); rs = st.executeQuery("select * from user_det"); int i=0; while(rs.next... a file to specific user , how to write code plzzz help. thank you in advance
writig a program - Java Beginners
writig a program  Write an application that reads in a five digit integer and determines whether or not it is a palindrome. if the number is not five digits long, displays an error message indicating the problem to the user
Convert Hexadecimal number into Integer
extracted from the specified String. The result is an integer that represents... to convert hexadecimal data into integer. The java.lang package provides the functionally to convert the hexadecimal data into an integer type data.  Code
Java SAX Examples
program that determines whether a  XML document is well-formed... From the XML File Here you will learn to retrieve data from XML file using SAX parser. We use the JAXP APIs to retrieve data from XML document . XML
The largest integer among the X number
The largest integer among the X number  Write an application program that prompts the user to key in a whole number X. The user is then prompted... information : a) The largest integer among the X number of integers keyed in b
Integer value to string - Swing AWT
Integer value to string  How can we convert an integer type into String ,so that we can select some integers from list and sum them and add to a textfield. Here the problem is when we are going to add Integer to TextField.  
Reads the character at buffer's current position.
Reads the character at buffer's current position. In this tutorial you will see how to read the character at buffer's current position. The get method actually get the value from current position and increment its position also. 

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.