Question

Assignment 5 Due Apr 5 by 11:59pm Points 100 Submitting a file upload A5 Wrapper Classes Pig Latin Access A5 from pdf assig
AS 15. Pig Latin Write a program that reads a sentence as input and converts each word to Pig Latin. In one version of Pig
Assignment 5 Due Apr 5 by 11:59pm Points 100 Submitting a file upload A5 Wrapper Classes "Pig Latin" Access A5 from pdf assigament file t Turn in the following files aSmain java program compile and run screenshots design document
AS 15. Pig Latin Write a program that reads a sentence as input and converts each word to "Pig Latin". In one version of Pig Latin, you convert a word by removing the first letter, placing that letter at the end of the word, and then appending “ay" to the word. Here is an exam ple: English: Pig Latin: I SLEPT MOST OF THE NIGHT IAY LEPTSAY OSTMAY FOAY HETAY IGHTNAY
0 0
Add a comment Improve this question Transcribed image text
Answer #1

import java.util.Scanner; terminated> a5Main [Java Application CAProgram FilesJavaýdk1.8.0 73binjavaw.exe (Ap Enter a english

import java.util.Scanner;

public class a5Main {
        
        public static void main(String args[]) {
                Scanner in = new Scanner(System.in);
                
                System.out.println("Enter a english sentence: ");
                String line = in.nextLine();
                
                String result = new PigLatinator(line).convertToPigLatin();
                
                System.out.println("Pig Latin text: " + result);
                in.close();
        }
}

class PigLatinator {
        public String data;

        public PigLatinator(String data) {
                this.data = data;
        }
        
        public String convertToPigLatin() {
                String words[] = data.split("\\s+");
                
                String result = "";
                for(int i=0; i<words.length; i++) {
                        String w = words[i];
                        result += w.substring(1) + w.charAt(0) + "AY" + " ";
                }
                
                return result.trim();
        }
}


Hi. please find the answer above.. i have given comments so that it is very easy for you to understand the flow. In case of any doubts, please ask in comments. If the answer helps you, please upvote. Thanks!

Add a comment
Know the answer?
Add Answer to:
Assignment 5 Due Apr 5 by 11:59pm Points 100 Submitting a file upload A5 Wrapper Classes "Pig Lat...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • JAVA PROGRAMMING LANGUAGE!!!! Pig Latin Write a program that reads a sentence as input and converts...

    JAVA PROGRAMMING LANGUAGE!!!! Pig Latin Write a program that reads a sentence as input and converts each word to "Pig Latin". In one version of Pig Latin, you convert a word by removing the first letter, placing that letter at the end of the word, and then appending "ay" to the word. Here is an example: English:                       I SLEPT MOST OF THE NIGHT Pig Latin :                   TAY LEPTSAY OSTMAY FOÀY HETAY 1GHTNAY make sure that there are two...

  • Assignment 6 Due Oct 27 by 11:59pm Points 100 Submitting a file upload Assignment 6: What...

    Assignment 6 Due Oct 27 by 11:59pm Points 100 Submitting a file upload Assignment 6: What happens to the demand curve facing a Starbucks shop when a Dunkin' Donuts store opens next to it? What can Starbucks do to maintain its business?

  • Nursing journal assignment Submit Assignment Due Sunday by 11:59pm Points 100 Submitting a file upload Nursing...

    Nursing journal assignment Submit Assignment Due Sunday by 11:59pm Points 100 Submitting a file upload Nursing journal: Locate one nursing journal article pertaining to a health problem. Read the article and summarize the article in a paragraph of 300-350 words (cite your material in APA format) Next. Previous

  • Module 13 Review Questions Due Apr 14 by 11:59pm Points 10 Submitting a file upload This chapter ...

    Module 13 Review Questions Due Apr 14 by 11:59pm Points 10 Submitting a file upload This chapter examines the basic features of three major business forms-sole proprietorships, partnerships, and corporations -and some of the important advantages and disadvantages of each. The chapter also covers briefly other types of business organizations, including limited liability companies, joint ventures, syndicates, joint stock companies, business trusts, and cooperatives. Discuss private franchises and submit your answer to the review question. Module 13 Review Questions Due...

  • disregard Final Project 2 Due Sunday by 11 59pm Points 100 Submitting the upload Instructions For...

    disregard Final Project 2 Due Sunday by 11 59pm Points 100 Submitting the upload Instructions For this assignment, you will create flowchart using Flowgorithm and Pseudocode for the following program example You are to design a program for Alexander's Coffee Shop providing customer research data When a customer places an order, the clerk asks the customer for their zip code and age. The clerk enters this data as well as the number of ems purchased. The program should operate continuously...

  • Challenge: Recursion and Python Turtle Graphics Submit Assignment Due Friday by 11:59pm Points 100 Submitting a...

    Challenge: Recursion and Python Turtle Graphics Submit Assignment Due Friday by 11:59pm Points 100 Submitting a file upload Available after Nov 9 at 12am Challenge: Recursion and Python Turtle Graphics Description: Write a program that draws a picture using Python e, recursion, and Turtle graphics e. Purpose: The purpose of this challenge is to provide experience working with recursione in Pythone. It also provides experience working with Turtle graphics in Pythone Requirements: Recursion and Python Turtle Graphics provides information on...

  • Assignment 4 Due Mar 22 by 11:59pmPoints 100 Submitting a file upload A4 OOP 2 "Car...

    Assignment 4 Due Mar 22 by 11:59pmPoints 100 Submitting a file upload A4 OOP 2 "Car Instrument Simulator" Access A4 from pdf assignment file & Turn in the following files: a4main.java FuelGauge.java Odometer.java program compile and run screenshots design document (including UML) A4 10. Car Instrument Simulator For this assignment, you will design a set of classes that work together to simulate a car's fuel gauge and odometer. The classes you will design are the following: · The Pue|Gauge Class:...

  • Elasticity Submit Assignment nouncements ignments cussions Due Thursday by 11:59pm Points 10 Submitting a text entry...

    Elasticity Submit Assignment nouncements ignments cussions Due Thursday by 11:59pm Points 10 Submitting a text entry box or a file upload Available Mar 23 at 10am - Mar 26 at 11:59pm 4 days des ple Solve the following two problems and show all of your work. Provide your answers on word document and submit online. UI abus 1. Global use of crude oil fell from 64million barrels per day in 1980 to 58 million barrels per day in 1982. During...

  • Unit 5 Assignment Submit Assignment pements Due Dec 1 by 11:59pm Points 50 Submitting a text...

    Unit 5 Assignment Submit Assignment pements Due Dec 1 by 11:59pm Points 50 Submitting a text entry box or a file upload ation Instructions The purpose of this assignment is to provide advice based on two fact patterns that include several legal problems as they relate to collective bargaining and unions. Please read the following (two) scenarios and respond to the questions below: Scenario 1 A large company is planning to downsize. A consultant suggests the following: • It makes...

  • 9:09 PM Fri Sep 27 Ass1.pdf 9/21/2019 Ass1 Submit Assignment Due Sunday by 11:59pm Points 5...

    9:09 PM Fri Sep 27 Ass1.pdf 9/21/2019 Ass1 Submit Assignment Due Sunday by 11:59pm Points 5 Submitting a file upload File Types zip Goals: Write a C++ class with separate.h and.cpp file, use partially filled arrays, Create a new class called Library that uses a private string array to store the list of books The starter code can be downloaded from https://github.com/pisan 342/ass 1-starter (https://github.com/pisan 342/ass 1-starter) You need to submit ass1.zip with the following files in it. Put all...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT