Tested the input command

This commit is contained in:
Sage Burger 2023-08-20 16:30:09 +02:00
parent 220de89555
commit a9e1700ed2
3 changed files with 19 additions and 1 deletions

Binary file not shown.

Binary file not shown.

View file

@ -1,5 +1,7 @@
import java.util.Random;
import javax.swing.JOptionPane;
public class Testcode {
public static void main(String[] args) {
System.out.println("A code request you have made,");
@ -24,5 +26,21 @@ public class Testcode {
System.out.println("The sum of " + x + " " + y + " and " + z + " is: " + sum);
System.out.println("May the code be with you!");
// Testing Inputs with a gap text
// Display a popup dialog and get user input
String a = JOptionPane.showInputDialog("Please enter a verb (-ing):");
String b = JOptionPane.showInputDialog("Please enter a location:");
if ((a == null || a.trim().isEmpty()) && (b == null || b.trim().isEmpty())) {
System.out.println("No words entered or both canceled.");
} else if (a == null || a.trim().isEmpty()) {
System.out.println("The verb was not entered or canceled.");
} else if (b == null || b.trim().isEmpty()) {
System.out.println("The location was not entered or canceled.");
} else {
System.out.println("They were " + a + " throw a " + b );
}
}
}