1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
BlackZzzverrR [31]
4 years ago
11

Design and code a Swing GUI to translate text that is input in english into pig latin. You can assume that the sentence contains

no punctuation. the rules for pig latin are as follows : for words that begin with consonants, move the leading consonant to the end of the word and add "ay" thus "ball" becomes "allbay" for words that begin with vowels add "way" to the end of the word thus "all" becomes "allway" use a flow layout with a jtextarea for the source text and a seperate jtextarea for the translated text add a jbutton with an event to perform the translation.
Computers and Technology
1 answer:
Whitepunk [10]4 years ago
5 0

Answer:

Code given below

Explanation:

import javax.swing.*;

import java.util.*;

import java.awt.*;

import java.awt.event.*;

public class PigLatin extends JFrame

{

private JLabel prompt;

private JTextField input;

private JTextArea output;

private int count;

public PigLatin()

{

super( "Pig Latin Generator" );

prompt = new JLabel( "Enter English phrase:" );

input = new JTextField( 30 );

input.addActionListener(

new ActionListener() {

public void actionPerformed( ActionEvent e )

{

String s = e.getActionCommand().toString();

StringTokenizer tokens = new StringTokenizer( s );

count = tokens.countTokens();

while ( tokens.hasMoreTokens() ) {

count--;

printLatinWord( tokens.nextToken() );

}

}

}

);

output = new JTextArea( 10, 30 );

output.setEditable( false );

Container c = getContentPane();

c.setLayout( new FlowLayout() );

c.add( prompt );

c.add( input );

c.add( output );

setSize( 500, 150 );

show();

}

private void printLatinWord( String token )

{

char letters[] = token.toCharArray();

StringBuffer schweinLatein = new StringBuffer();

schweinLatein.append( letters, 1, letters.length - 1 ) ;

schweinLatein.append( Character.toLowerCase( letters[ 0 ] ) );

schweinLatein.append( "ay" );

output.append( schweinLatein.toString() + " " );

if ( count == 0 )

output.append( "\n" );

}

public static void main( String args[] )

{

PigLatin app = new PigLatin();

app.addWindowListener(

new WindowAdapter() {

public void windowClosing( WindowEvent e )

{

System.exit( 0 );

}

}

);

}

}

You might be interested in
A(n) monitoring vulnerability scanner is one that listens in on the network and determines vulnerable versions of both server an
Tom [10]

Answer: Passive

Explanation: Passive scanning is the process that scans the possibility of the risk that can arise while data is received starting port to the destination. It does the scanning between the server and the client software to define vulnerability .

It cannot work in those network which don't persist the traffic.No false data that is present in the application is detected by it if the data is unclear.

5 0
3 years ago
Write an algorithm of telephone call system​
ivolga24 [154]

Answer:

this is the correct answer

3 0
3 years ago
Read 2 more answers
The base class Pet has private fields petName, and petAge. The derived class Dog extends the Pet class and includes a private fi
Lapatulllka [165]

Answer:

Hello attached is the Java program written to solve the problem

The Pet.java and Dog.java files are unaltered

Explanation:

The input and output  codes are attached as well i.e the second image is the input while the third image is the output code

5 0
3 years ago
Write a function endpoints that takes a list of numbers (eg. [5, 10, 15, 20, 25]) and returns a new list of only the first and l
Ne4ueva [31]

I included a picture of my code below. Best of luck with your assignment.

5 0
3 years ago
Linux is: Select one: a. primarily concerned with the tasks of end users. b. designed for specific machines and specific micropr
ivann1987 [24]

Answer:

C. an example of open-source software.

Explanation:

open-source software is the type of software in which anyone can access, it can also be shared And modified by anyone simply because ita accessible to the public.

Hence and open source software's source code can be

inspected, enhanced and modified by anyone. A typical example is Linux.

7 0
3 years ago
Other questions:
  • ________ symbol is used in the "Advanced" section of the time range picker to round down to nearest unit of specified time.
    8·1 answer
  • Can anybody come up with a catchy title for this?
    11·1 answer
  • When you park on a hill, think about which way _____.
    6·2 answers
  • Big data refers to huge collections of data that are difficult to process, analyze, and manage using conventional data tools. It
    13·1 answer
  • The computer output for integer programs in the textbook does not include reduced costs, dual values, or sensitivity ranges beca
    14·1 answer
  • To view the results of a query, open it by pressing and holding or right-clicking the query in the navigation pane and tapping o
    10·1 answer
  • Which result is most likely if a network packet has no header?
    9·2 answers
  • What Are the Benefits of Using Leads Automation Tool?
    5·1 answer
  • Generalized goals are more likely to be achieved than specific goals. True or False
    7·1 answer
  • Use the drop-down menus to complete the statements about Search Folders.
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!