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

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 5 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
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
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
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
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
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
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
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
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
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   
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
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
identify admin from user when logging in - Java Beginners
identify admin from user when logging in  hi everyone... and password were requested for a user to log-in, but there are 2 kinds of user types(admin and user).and the usertype are also saved in the database. my question is,how
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 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
Restricting the user from filling the data in a textfield using html
Restricting the user from filling the data in a textfield using html  I got a requirement like this, If the user is trying to fill a text field, i have to restrict him
simple code to login user & authenticate it from database mysql
simple code to login user & authenticate it from database mysql  Sir, I am creating a login page which contain userid & password. Iwant to authenticate user from mysql database. please tell me the code for it. Thanks
how to retreive data from database of a particular user after login
how to retreive data from database of a particular user after login  ... the user information.. now their is a login and registration page for newuser. after the user has filled the form he should go to the welcome page where he
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 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 with their mobile number daily one health tip is to sent to their respective mobiles
retrive mails from user using java code - Java Beginners
retrive mails from user using java code   how to retrive mails as user "username"??? using java for ex: class Mail{ private String subject... to retrive all mails for user "userName" //and return a set of mail objects
Calling In JavaScript Functions from HTML Form To Validate User Entered Data
Calling In JavaScript Functions from HTML Form To Validate User Entered Data  Hello, I have been working for days on my web Form assignment and editing my html to call my functions to validate the user entered data
Convert a String into an Integer Data
program we have prompted the user to enter the a String and then reads the data... Convert a String into an Integer Data  ... a string type data into an integer type. The java.lang package provides
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
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 "
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
 

 

 

DMCA.com