Tested the input command
This commit is contained in:
		
							parent
							
								
									220de89555
								
							
						
					
					
						commit
						a9e1700ed2
					
				
					 3 changed files with 19 additions and 1 deletions
				
			
		
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							|  | @ -1,5 +1,7 @@ | ||||||
| import java.util.Random; | import java.util.Random; | ||||||
| 
 | 
 | ||||||
|  | import javax.swing.JOptionPane; | ||||||
|  | 
 | ||||||
| public class Testcode { | public class Testcode { | ||||||
|     public static void main(String[] args) { |     public static void main(String[] args) { | ||||||
|         System.out.println("A code request you have made,"); |         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("The sum of " + x + " " + y + " and " + z + " is: " + sum); | ||||||
| 
 | 
 | ||||||
|         System.out.println("May the code be with you!"); |         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 ); | ||||||
|  |         } | ||||||
|     } |     } | ||||||
| } | } | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Sage Burger
						Sage Burger