Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Date: Thu, Feb 25, 2021 5:14 pm Good Evening, I am in need of your assistance. I am experiencing difficulty in solving this C shape

Date: Thu, Feb 25, 2021 5:14 pm

Good Evening,

I am in need of your assistance. I am experiencing difficulty in solving this C shape programming problem. I am in need of your help. Please see below. Thank you

For the input I got "i t", I should get the

output in pig latin " iway tay" but I get nothing. That goes the same for typing the word "string" to get ingstray. Do you know how I would fix this?

Heres my code:

static void Main(string[] args)

Console.WriteLine("Line:");

//get user line

string line = Console.ReadLine();

// split line into words

string[] words = line.Split(' ');

// iterate over words in the array

for (int i = 0; i < words.Length; i++)

{

// check if the word in the words array starts with vowel

if (isVowel(words[i]) == true)

{

words[i] = words[i] + "way";

}

else

{

string output;

string temp = words[i];

do

{

// parse the string using temp variables

output = temp.Substring(1) + temp[0];

if (isVowel(output) == true)

{

//add ay to the string

words[i] = output + "ay";

}

else

{

// parse the string

output = output.Substring(1) + output[0];

//add ay to the string

words[i] = output + "ay";

}

} while (isVowel(output) == false);\ }

}

// print the words

for (int i = 0; i < words.Length; i++)

{

Console.WriteLine(words[i]);

} Console.ReadLine();

// method to validate the word whether it is starts with vowel or not

static bool isVowel(string word)

{

if (word[0] == 'a' || word[0] == 'e' || word[0] == 'i' || word[0] == 'o' || word[0] == 'u')

{ return true;

} else

{ return false;

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

Modern Database Management

Authors: Jeff Hoffer, Ramesh Venkataraman, Heikki Topi

13th Edition Global Edition

1292263350, 978-1292263359

More Books

Students also viewed these Databases questions

Question

What are the main objectives of Inventory ?

Answered: 1 week ago

Question

Explain the various inventory management techniques in detail.

Answered: 1 week ago