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



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

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


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


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


Advertisement
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 Tutorials/Questions & Answers:
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
Advertisements
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
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
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
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   
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
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
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
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 code for print true if even and false if odd and print error if any float value with out using conditional and looping statement
java code for print true if even and false if odd and print error if any float value with out using conditional and looping statement  hi class Even{ public static void main(String[] arg){ int num=Integer.parseInt
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     
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
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
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
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
odd numbers with loop
odd numbers with loop  get the odd numbers till 100 with for,while loop   Java find odd numbers: class OddNumbers { public static void main(String[] args) { for(int i=1;i<=100;i
error in taking input from user.
error in taking input from user.  //i m having problem inputting the array from user.my program is import java.io.*; class bubble { public static void main(String args[]) { int a[]=new int[20]; int i=0; BufferedReader br=new
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
A program to find the sum of odd number
input from the user, applying a loop which will keep on executing up to the number provided by user. Within the loop checking for odd number...A program to find the sum of odd number In this section you will learn how
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
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
Fetch user records from a table in database
Fetch user records from a table in database  Hi. I have a field in database named stages. its datatype is varchar(60). It contains values chennai,trichy,kanchipuram for a single record. I have to retrieve these data from
How To Read Integer From Command Line In Java
How To Read Integer From Command Line In Java In this section we will discuss about how an integer can be read through the command line. In Java all... Integer long Long short Short parseXXX() method of these wrapper
Find Cylinder area By inputting value from user
Find Cylinder area By inputting value from user  Hello Sir I need the code for calculating the area of a cylinder in which it asks radius value from user and then calculate area using this radius value. Please provide me
Insert image from user using and save in database
Insert image from user using and save in database  when i am trying to upload a image from user and trying to save into oracle9i database... description The server encountered an internal error () that prevented it from
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
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
 

 

 

DMCA.com