Odd, Even number checker in Java

Download is available until [expire_date]
  • Version
  • Download 74
  • File Size 3.13 KB
  • File Count 1
  • Create Date May 12, 2016
  • Last Updated May 12, 2016

Odd, Even number checker in Java

Odd, Even number checker in Java

A java program that wil determine if the number entered by the user is an odd or even number. The java program has two versions the gui and the console based program. The gui uses swing library and the console uses scanner class.

Happy programming!

Source code:

import javax.swing.*;
class OddEvenCheckerGUI {
public static void main(String[] args) {
String input1;	
double num=0, remainder=0;
String cont="n";

input1 = JOptionPane.showInputDialog(null,"enter a number: ");

remainder=num % 2;

if (remainder ==0){
JOptionPane.showMessageDialog(null, num + " is even number");
JOptionPane.showMessageDialog(null, num + " is odd number");

	cont = JOptionPane.showInputDialog(null,"Continue? y or n ");
	}while (cont.matches("y"));
	JOptionPane.showMessageDialog(null,"Program Closing");

, , , , , ,

Post navigation

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.