Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

8-7. Modify exercise 7-2 on comparing strings so it is now done in a GUI application frame class definition with a main instead of a

8-7. Modify exercise 7-2 on comparing strings so it is now done in a GUI application frame class definition with a main instead of a console application. The GUI components will be data fields of the class definition. The prompts will now be in labels and the input will now be textfields. The user will hit enter in the second textfield to get the results in two other answer labels. The results (which is greater and the difference amount) will be in these two other answer labels. Declare everything at the top, use the constructor to add the components to your container (use background and foreground colors and the flow layout), and use actionPerformed to do three things: get the text out of the textfields for the two strings (instead of readLines), to perform the nested if else with the comparisons, and the setting of the answers in the two answer labels - which is greater and the difference (instead of printlns). Use a little main method to construct yourself. Set the size so the components flow properly (make sure labels are next to textfields, etc.) and there is not a lot of extra space. Take a picture of the output GUI frame with which will copy the frame, paste into paint, and save as a .jpg file. Attach the . java program file .jpg output file and submit.

image text in transcribed

* Bil1 Wohlleber zxercise 72 This program will compare 2 strings / mport java. io. ublic class ex72 public static void main(String[] args) throws IOException \{ String s1, s2; BufferedReader br = new BufferedReader (new InputStreamReader (System. in)); System. out. print ("Enter a string: "); s1= br. readLine () ; System. out. print("Enter a string: "); s2= br. readLine () ; if (s1. equals (s2))//s1==s2 System. out. println( "Same string"); else if (sl. equalsIgnoreCase (s2)) System. out. println ("Same string - different case"); else if (s1. compareTo (s2)>0)//s1>s2 System. out. println (s1++is alphabetically greater than " +s2) else //s1

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Pro PowerShell For Database Developers

Authors: Bryan P Cafferky

1st Edition

1484205413, 9781484205419

More Books

Students also viewed these Databases questions