LessHundred.java
This program was created once again with that dreadful old school Java GUI known as JOptionPane.
What it does is that it takes two positive numbers and check if their sum is bigger than 100.
If so, return true or else return false.
Unfortunately, this program results in a logical error since it should return false if it is bigger than 100 and true if it isn’t bigger.
The code has been modified slightly and now uploaded to the site.
JOptionPane Code Snippet
/*
Author: ENTPRESTIGIOUS
Date Finished: April 13, 2021
Compiler: JDK 11.0.10 LTS
Link: https://edabit.com/challenge/FSKb2sKrGoejfJLrd
*/
import javax.swing.JOptionPane;
public class LessHundred {
public static void main(String[] args){
//boolean checker = true;
JOptionPane.showMessageDialog(null, "Welcome!\nPress enter to continue...");
//while (checker == true){
String first = JOptionPane.showInputDialog(null, "Please enter the first number to determine whether sum is greater than 100! Press the X on the top right to exit!");
String second = JOptionPane.showInputDialog(null, "Please enter the second number to determine whether sum is greater than 100! Press the X on the top right to exit!");
int firstNum = Integer.parseInt(first);
int secondNum = Integer.parseInt(second);
boolean result = lessThan100(firstNum, secondNum);
JOptionPane.showMessageDialog(null, "Is the sum greater than 100?: " + result);
//}
}
public static boolean lessThan100(int a, int b){
if (a + b > 100){
return true;
}
return false;
}
}