Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Question : Write a program that accepts a grammatical string of Eng-- (you may a

ID: 669604 • Letter: Q

Question

Question:

Write a program that accepts a grammatical string of Eng-- (you may assume it is grammatical) and outputs a string that is the Eng-- string translated into Eng++.

Definition of Eng++:

• three suffixes or “markers”:

-ga (marks a noun as the subject of a sentence)

-o (marks a noun as the direct object of the verb)

-ka (marks the verb in a sentence only if the sentence is a question)

Note that adjectives are not marked.

• three verbs: caught, kissed, is

• three nouns: man, woman, fish

• three adjectives: strong, short, red •

Sentences may not begin with a space, but words are separated by exactly one space.

• Word order:

Both declarative sentences and questions have exactly the same word order. The subject is the first word in the sentence, the verb is the last. If the verb is either “caught” or “kissed”, then the direct object (a noun) is in the middle, otherwise an adjective is in the middle. o Declarative sentences do not end with a period in Eng++, but questions do end with the marker –ka on the last word of the question which is a verb.

examples:

woman-ga man-o kissed

fish-ga strong is

man-ga fish-o caught

man-ga red is-ka

fish-ga short is

Definition of Eng--:

• three nouns: man, woman, fish

• three adjectives: strong, short, red

• three verbs: caught, kissed, is

• two articles: a, the

o The articles can only come before a noun, and are optional. So The man caught fish, and, Man caught fish, and, The man caught the fish and Man caught the fish are all grammatical in Eng--.

• All sentences are between three and five words long.

• Sentences may not begin with a space, and words are separated by one or more spaces.

Word order:

o For declarative sentences: The subject (a noun) always begins a sentence (with or without a preceding article), the verb follows the subject. If the verb is either “caught” or “kissed”, then the direct object (a noun) follows the verb (with or without an article), otherwise an adjective follows the verb.

o For questions: Questions in Eng-- can only use the verb “is”. The verb (“is”) always begins a question, the subject (a noun) is the middle word optionally preceded by an article. An adjective is always the last word in a question.

o Declarative sentences do not end with a period in Eng-- and questions do not end with a question mark.

NOTE: Can someone solve this without using functions and instead, using a lot of while-loops and 'if' statements instead?

Explanation / Answer

#include <bits/stdc++.h>
using namespace std;

bool en(string s){
   if (s[0] == 'w' || s[0] == 'W' || s[0] == 'm' || s[0] == 'M' || s[0] == 'f' || s[0] == 'F'){
       size_t found = s.find("-ga");
       if (found != string::npos){
           int len = s.length();
           if (s[len-1] == 'd' || s[len-1] == 'D' || s[len-1] == 't' || s[len-1] == 'T' || s[len-1] == 's' || s[len-1] == 'S') return true;
           else{
               size_t found = s.find("-ka")
               if (found != string::npos)
                   return true;
               return false;
           }
       }
       return false;  
   }
   return false;
}

int main(){
   string s;
   cout << "Enter the String : ";
   cin >> s;
   cout << en(s) << endl;
   return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote