Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program that reads a sentence as input (from keyboard) and converts each word to pig Latin. In this version of Pig Latin, you

Write a program that reads a sentence as input (from keyboard) and converts each word to pig Latin. In this 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 (all uppercase). For example, if the input is I am Fred then the output would be IAY MAAY REDFAY.

This is what I have:

public class pigLatin{ public static void main(String[] args){ Scanner sw = new Scanner(System.in); System.out.println("Type in a sentence :: "); String Input = sw.nextLine(); StringBuilder str = new StringBuilder(Input); String[] words = Input.split(" "); for(String w: words){ char f = str.charAt(0); str.deleteCharAt(0); System.out.print(str.append(f+"ay")); } } }

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

Database Driven Web Sites

Authors: Mike Morrison, Joline Morrison

1st Edition

061901556X, 978-0619015565

More Books

Students also viewed these Databases questions

Question

How wide are Salary Structure Ranges?

Answered: 1 week ago