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
If powerpoint is allowed to dominate a speech, it can divert attention from the speaker's message.
aev [14]
<span>The statement that if powerpoint is allowed to dominate a speech, it can divert attention from the speaker's message is true.
</span>
PowerPoint provides a common infrastructure, a template for the organization of speech, and for the logic of argumentation<span> and presentations should use both visual and verbal forms of presentation in order to dominate.</span>
3 0
3 years ago
Sound effects are located within the Microsoft® Office applications. In the Insert ribbon, what would you select to find pre-pro
babymother [125]
Sometimes clip art has sound files in them, it may have gotten updated though, that answer is the only one that could work.
7 0
3 years ago
Which shortcut key in Microsoft Word 2016 will launch Spell Checker?
Pie

Alt + F7 will launch spell checker

4 0
3 years ago
Read 2 more answers
What is ‘White-Box’ testing?
Sergeeva-Olga [200]

Answer:

 The white box testing is the method in which it basically test the internal structure and working application in the software testing.

In the white box testing the programming skills are require for designing the various test cases.

White box testing is also known as open box testing and it require the specific knowledge of the programming language for examine the particular software testing output.

4 0
3 years ago
Read 2 more answers
Iii. Write the pseudocode for a program to take two integer inputs and the operator from user and
Katen [24]

Answer:

The pseudocode is as follows:

Input num1, num2

input operator

print num1 + num2

print num1 - num2

print num1 * num2

if num2 != 0

    print num1 / num2

else

    print "Cannot divide by 0"

Explanation:

This gets input for both numbers

Input num1, num2

This gets input for the operator

input operator

This prints the sum

print num1 + num2

This prints the difference

print num1 - num2

This prints the product

print num1 * num2

This prints the division if the divisor is not 0

<em>if num2 != 0</em>

<em>     print num1 / num2</em>

<em>else</em>

<em>     print "Cannot divide by 0"</em>

<em />

6 0
3 years ago
Other questions:
  • How to get points on Brainly?<br> List at least two ways if you can.
    10·2 answers
  • You would like to search for information about storms but not tornadoes. What type of search strategy may be useful?
    10·2 answers
  • Step 1: Configure the initial settings on R1. Note: If you have difficulty remembering the commands, refer to the content for th
    10·1 answer
  • In order to estimate the percentage of defects in a recent manufacturing batch, a quality control manager at Intel selects every
    5·1 answer
  • The most common Unicode transformation formats are UTF- ______ and UTF-16.
    9·1 answer
  • What section in an ethernet frame will you find a Virtual Local Area Network (VLAN) header?
    6·1 answer
  • Write a function in Java to implement the following logic:
    13·1 answer
  • List two major problems that could be addressed by futuring.
    15·1 answer
  • PLEASE I NEED HELP, WILL MARK BRAINLYEST!!! 50 POINTS!!!
    14·1 answer
  • What skill would be easiest to learn from a simulation video game?
    8·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!