How to write java application that reads an integer, then determines and display whether it's odd or even. Use the remainder operator.
import javax.swing.JOptionPane;
public class BasicGUI {
public static void main(String[] args) {
// TODO Auto-generated method stub
//Showing the Welcome message in Dialog Box
JOptionPane.showMessageDialog(null, "Welcome");
//Asking the User to input a number
String input = JOptionPane.showInputDialog("Enter a Number");
//Converting the string version of number to Integer version
int num = Integer.parseInt(input);
//Showing the appropriate message for even or odd
if(num%2==0){
JOptionPane.showMessageDialog(null, num+" is even number");
}
else{
JOptionPane.showMessageDialog(null, num+" is odd number");
}
}
}
Output Screens:


How to write java application that reads an integer, then determines and display whether it's odd...
Write an application in java that reads in a five-digit integer and determines whether it is a palindrome. If the number is not five digits long, display an error message and allow the user to enter a new value. Tips: 1. Determine the number of digits in the value input by the user , i.e. prompt the user to enter the number of digits of the number. Use a while loop to determine whether the user input contains the proper...
For JAVA- Write an application that reads three nonzero values entered by the user and determines and prints whether they could represent the sides of a triangle.
8) Write the Java code to Declare an Integer Number and Initialize it to value 10. Then use Ternary Operator to Check if the Integer Number is Odd or Even and print out the Result Odd or Even.
A java program Write a program that prompts for and reads in a positive integer into a variable n. Your program should then sum the first n ODD integers and display the sum. For example, if 3 is entered for n, your program should display the the sum 1 + 3 + 5. If 5 is entered, your program should display the sum 1 + 3 + 5 + 7 + 9. What is the...
JAVA: 4.31 (Palindromes) A palindrome is a sequence of characters that reads the same backward as forward. For example, each of the following five-digit integers is a palindrome: 12321, 55555, 45554 and 11611. Write an application that reads in a five-digit integer and determines whether it’s a palindrome. If the number is not five digits long, display an error message and allow the user to enter a new value.
Draw a Raptor flowchart that inputs 50 integer numbers and accumulates only the input integer numbers that are odd and less than 45. Display the final accumulated value before ending the flowchart. Hint: MOD operators both give the remainder when the value on the left of the operator is divided by the operator on the right. Use MOD operator to check whether an integer number is odd or even. number mod 2 returns 1 , then the number is odd....
Write a Java application that determines whether any of several department store customers has exceeded the credit limit on a charge account. For each customer, the following facts are inputted: -Balance at beginning of month -Total amount of all items charged by the customer this month -Total amount of all credits applied to the customer’s account this month -Allowed credit limit Use the value of -1 as a sentinel value to quit the program. The program should input all these...
Write a Java console application that reads a string from the keyboard and tests whether it contains a valid date. Display the date and a message that indicates whether it is valid. If it is not valid, also display a message explaining why it is NOT valid. The input date will have the format mm/dd/yyyy. A valid month value mm must be from 1 to 12 (January is 1). You can use: String monthPart = inputDate.substring(0, 2); int month =...
Java Programming Write a method named isEven that accepts an integer argument. The method should return true if the argument is even, or false if not. The program’s main method should use a loop to generate a random integer. The number of random integers is provided by a user, who must enter a number greater than 10. The loop should then invoke the isEven method to determine whether each integer is even or odd, display the random number and the...
Write a Java application that determines whether any of several department store customers has exceeded the credit limit on a charge account. For each customer, the following facts are inputted: Account number Balance at beginning of month Total amount of all items charged by the customer this month Total amount of all credits applied to the customer’s account this month Allowed credit limit Use the value of -1 as a sentinel value to quit the program. The program should input...