Hello, and thank you for hwlping me with this run-in with trouble.
I am making a script for pig latin transulation, and there is something wrong with the "if" statement in line 51. Here is the code so far: - #include <iostream>
-
#include <stdlib.h>
-
#include <string.h>
-
using namespace std;
-
string platin(string original);
-
int main()
-
{
-
string bub;
-
do {
-
cout << "Enter One Word: ";
-
getline (cin, bub);
-
cout << "\n\nOriginal : " << bub << endl;
-
cout << "Pig Latin: " << platin(bub) << "\n\n" << endl;
-
} while (bub != "exit");
-
return 0;
-
}
-
-
string platin(string original)
-
{
-
string a;
-
string b;
-
string c;
-
string d;
-
string e;
-
string final;
-
int positionOne = 0;
-
int positionTwo = 0;
-
int positionThree = 0;
-
positionTwo = original.find(" ", positionThree);
-
positionThree = positionTwo;
-
a = original.substr(positionOne, (positionTwo - positionOne));
-
b = a[0];
-
c = a.substr(0, 2);
-
d = a.substr(0, 3);
-
if ((b == "a") || (b == "e") || (b == "i") || (b == "o") || (b == "u")) {
-
e = original + "yay";
-
}
-
else if (original == "nix") {
-
e = "ixnay";
-
}
-
else if (original == "scram") {
-
e = "amscray";
-
}
-
else if (original == "hour") {
-
e = "houray";
-
}
-
else if ((c == "aa") || (c == "ae") || (c == "ah") || (c == "ao") || (c == "aw") || (c == "ax") || (c == "ay") || (c == "ea") || (c == "eh") || (c == "er") || (c == "ey") || (c == "ia") || (c == "ih") || (c == "iy") || (c == "oh") || (c == "ow") || (c == "oy") || (c == "ua") || (c == "uh") || (c == "uw") || (c == "th") || (c == "dh") || (c == "sh") || (c == "zh") || (c == "ch") || (c == "jh") || (c == "ng") || (c == "hh") (c == "ph") || (c == "qu")) {
-
d = a.substr(2);
-
e = d + c + "ay";
-
}
-
else if ((d == b + "aa") || (d == b + "ae") || (d == b + "ah") || (d == b + "ao") (d == b + "aw") || (d == b + "ax") || (d == b + "ay") || (d == b + "ea") || (d == b + "eh") (d == b + "er") || (d == b + "ey") || (d == b + "ia") || (d == b + "ih") || (d == b + "iy") (d == b + "oh") || (d == b + "ow") || (d == b + "oy") || (d == b + "ua") || (d == b + "uh") (d == b + "uw") || (d == b + "th") || (d == b + "dh") || (d == b + "sh") || (d == b + "zh") (d == b + "ch") || (d == b + "jh") || (d == b + "ng") || (d == b + "hh") || (d == b + "ph") (d == b + "qu") || ) {
-
c = a.substr(3);
-
e = c + d + "ay";
-
}
-
else {
-
c = a.substr(1);
-
e = c + b + "ay";
-
}
-
positionOne = positionTwo;
-
final = final + e;
-
return final;
-
}
Please post code when you reply to this post. Thank you.
By the way, here are my compiler/envirnment specs.:
Envirnment : Dev-C++ 4.9.9.2
Compiler : GCC.exe
13 1541
Hello, and thank you for hwlping me with this run-in with trouble.
I am making a script for pig latin transulation, and there is something wrong with the "if" statement in line 51. Here is the code so far: - #include <iostream>
-
#include <stdlib.h>
-
#include <string.h>
-
using namespace std;
-
string platin(string original);
-
int main()
-
{
-
string bub;
-
do {
-
cout << "Enter One Word: ";
-
getline (cin, bub);
-
cout << "\n\nOriginal : " << bub << endl;
-
cout << "Pig Latin: " << platin(bub) << "\n\n" << endl;
-
} while (bub != "exit");
-
return 0;
-
}
-
-
string platin(string original)
-
{
-
string a;
-
string b;
-
string c;
-
string d;
-
string e;
-
string final;
-
int positionOne = 0;
-
int positionTwo = 0;
-
int positionThree = 0;
-
positionTwo = original.find(" ", positionThree);
-
positionThree = positionTwo;
-
a = original.substr(positionOne, (positionTwo - positionOne));
-
b = a[0];
-
c = a.substr(0, 2);
-
d = a.substr(0, 3);
-
if ((b == "a") || (b == "e") || (b == "i") || (b == "o") || (b == "u")) {
-
e = original + "yay";
-
}
-
else if (original == "nix") {
-
e = "ixnay";
-
}
-
else if (original == "scram") {
-
e = "amscray";
-
}
-
else if (original == "hour") {
-
e = "houray";
-
}
-
else if ((c == "aa") || (c == "ae") || (c == "ah") || (c == "ao") || (c == "aw") || (c == "ax") || (c == "ay") || (c == "ea") || (c == "eh") || (c == "er") || (c == "ey") || (c == "ia") || (c == "ih") || (c == "iy") || (c == "oh") || (c == "ow") || (c == "oy") || (c == "ua") || (c == "uh") || (c == "uw") || (c == "th") || (c == "dh") || (c == "sh") || (c == "zh") || (c == "ch") || (c == "jh") || (c == "ng") || (c == "hh") (c == "ph") || (c == "qu")) {
-
d = a.substr(2);
-
e = d + c + "ay";
-
}
-
else if ((d == b + "aa") || (d == b + "ae") || (d == b + "ah") || (d == b + "ao") (d == b + "aw") || (d == b + "ax") || (d == b + "ay") || (d == b + "ea") || (d == b + "eh") (d == b + "er") || (d == b + "ey") || (d == b + "ia") || (d == b + "ih") || (d == b + "iy") (d == b + "oh") || (d == b + "ow") || (d == b + "oy") || (d == b + "ua") || (d == b + "uh") (d == b + "uw") || (d == b + "th") || (d == b + "dh") || (d == b + "sh") || (d == b + "zh") (d == b + "ch") || (d == b + "jh") || (d == b + "ng") || (d == b + "hh") || (d == b + "ph") (d == b + "qu") || ) {
-
c = a.substr(3);
-
e = c + d + "ay";
-
}
-
else {
-
c = a.substr(1);
-
e = c + b + "ay";
-
}
-
positionOne = positionTwo;
-
final = final + e;
-
return final;
-
}
Please post code when you reply to this post. Thank you.
By the way, here are my compiler/envirnment specs.:
Envirnment : Dev-C++ 4.9.9.2
Compiler : GCC.exe
Hi Peter,
What is th eproblem with the if. Is it not compiling, or is it misbehaving....
Is it going to else when it shouldn't or is it going into the if when it shouldn't.
You are missing at least three sets of or signs.....try -
else if ((d == b + "aa") || (d == b + "ae") || (d == b + "ah") || (d == b + "ao") ||(d == b + "aw") || (d == b + "ax") || (d == b + "ay") || (d == b + "ea") || (d == b + "eh") ||(d == b + "er") || (d == b + "ey") || (d == b + "ia") || (d == b + "ih") || (d == b + "iy") ||(d == b + "oh") || (d == b + "ow") || (d == b + "oy") || (d == b + "ua") || (d == b + "uh")|| (d == b + "uw") || (d == b + "th") || (d == b + "dh") || (d == b + "sh") || (d == b + "zh")|| (d == b + "ch") || (d == b + "jh") || (d == b + "ng") || (d == b + "hh") || (d == b + "ph") ||(d == b + "qu") || ) {
-
-
(actually I added six, I hope that was all)
Hi Peter,
What is th eproblem with the if. Is it not compiling, or is it misbehaving....
Is it going to else when it shouldn't or is it going into the if when it shouldn't.
You are missing at least three sets of or signs.....try -
else if ((d == b + "aa") || (d == b + "ae") || (d == b + "ah") || (d == b + "ao") ||(d == b + "aw") || (d == b + "ax") || (d == b + "ay") || (d == b + "ea") || (d == b + "eh") ||(d == b + "er") || (d == b + "ey") || (d == b + "ia") || (d == b + "ih") || (d == b + "iy") ||(d == b + "oh") || (d == b + "ow") || (d == b + "oy") || (d == b + "ua") || (d == b + "uh")|| (d == b + "uw") || (d == b + "th") || (d == b + "dh") || (d == b + "sh") || (d == b + "zh")|| (d == b + "ch") || (d == b + "jh") || (d == b + "ng") || (d == b + "hh") || (d == b + "ph") ||(d == b + "qu") || ) {
-
-
(actually I added six, I hope that was all)
Well, that actually worked fantastically. I'm not quite sure what you did, but what ever it was, it worked. But, now the if statement on line 47 is having a new error. The debugger said:
"expected primary-expression before ')' token"
I cannot figure out how to solve this.
As for before, and now (for that matter), it is/was a compiler error.
And I'm not Peter...Its Parker.
Well, that actually worked fantastically. I'm not quite sure what you did, but what ever it was, it worked. But, now the if statement on line 47 is having a new error. The debugger said:
"expected primary-expression before ')' token"
I cannot figure out how to solve this.
As for before, and now (for that matter), it is/was a compiler error.
And I'm not Peter...Its Parker.
Okay, there is an update.
I'm having a compiler error.
Here is the code I am now working with: - #include <iostream>
-
#include <stdlib.h>
-
#include <string.h>
-
using namespace std;
-
string platin(string original);
-
int main()
-
{
-
string bub;
-
do {
-
cout << "Enter One Word: ";
-
getline (cin, bub);
-
cout << "\n\nOriginal : " << bub << endl;
-
cout << "Pig Latin: " << platin(bub) << "\n\n" << endl;
-
} while (bub != "exit");
-
return 0;
-
}
-
-
string platin(string original)
-
{
-
string a;
-
string b;
-
string c;
-
string d;
-
string e;
-
string final;
-
int positionOne = 0;
-
int positionTwo = 0;
-
int positionThree = 0;
-
positionTwo = original.find(" ", positionThree);
-
positionThree = positionTwo;
-
a = original.substr(positionOne, (positionTwo - positionOne));
-
b = a[0];
-
c = a.substr(0, 2);
-
d = a.substr(0, 3);
-
if ((b == "a") || (b == "e") || (b == "i") || (b == "o") || (b == "u")) {
-
e = original + "yay";
-
}
-
else if (original == "nix") {
-
e = "ixnay";
-
}
-
else if (original == "scram") {
-
e = "amscray";
-
}
-
else if (original == "hour") {
-
e = "houray";
-
}
-
else if ((c == "aa") || (c == "ae") || (c == "ah") || (c == "ao") || (c == "aw") || (c == "ax") || (c == "ay") || (c == "ea") || (c == "eh") || (c == "er") || (c == "ey") || (c == "ia") || (c == "ih") || (c == "iy") || (c == "oh") || (c == "ow") || (c == "oy") || (c == "ua") || (c == "uh") || (c == "uw") || (c == "th") || (c == "dh") || (c == "sh") || (c == "zh") || (c == "ch") || (c == "jh") || (c == "ng") || (c == "hh") (c == "ph") || (c == "qu")) {
-
d = a.substr(2);
-
e = d + c + "ay";
-
}
-
else if ((d == b + "aa") || (d == b + "ae") || (d == b + "ah") || (d == b + "ao") || (d == b + "aw") || (d == b + "ax") || (d == b + "ay") || (d == b + "ea") || (d == b + "eh") || (d == b + "er") || (d == b + "ey") || (d == b + "ia") || (d == b + "ih") || (d == b + "iy") || (d == b + "oh") || (d == b + "ow") || (d == b + "oy") || (d == b + "ua") || (d == b + "uh") || (d == b + "uw") || (d == b + "th") || (d == b + "dh") || (d == b + "sh") || (d == b + "zh") || (d == b + "ch") || (d == b + "jh") || (d == b + "ng") || (d == b + "hh") || (d == b + "ph") || (d == b + "qu")) {
-
c = a.substr(3);
-
e = c + d + "ay";
-
}
-
else {
-
c = a.substr(1);
-
e = c + b + "ay";
-
}
-
positionOne = positionTwo;
-
final = final + e;
-
return final;
-
}
Here is the compiler error I keep getting:
"std::operator== [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>](((const std::basic_string<char, std::char_traits<char>, std::allocator<char> >&)((const std::basic_string<char, std::char_traits<char>, std::allocator<char> >*)(&c))), ((const char*)"hh"))' cannot be used as a function"
This is for line 47.
Thank you.
else if ((c == "aa") || (c == "ae") || (c == "ah") || (c == "ao") || (c == "aw") || (c == "ax") || (c == "ay") || (c == "ea") || (c == "eh") || (c == "er") || (c == "ey") || (c == "ia") || (c == "ih") || (c == "iy") || (c == "oh") || (c == "ow") || (c == "oy") || (c == "ua") || (c == "uh") || (c == "uw") || (c == "th") || (c == "dh") || (c == "sh") || (c == "zh") || (c == "ch") || (c == "jh") || (c == "ng") || (c == "hh") (c == "ph") || (c == "qu")) {
}
.
Sorry Parker (It was late and I glanced at your name, my bad!!)
Line 47 also has a missing or -
-
else if ((c == "aa") || (c == "ae") || (c == "ah") || (c == "ao") || (c == "aw") || (c == "ax") || (c == "ay") || (c == "ea") || (c == "eh") || (c == "er") || (c == "ey") || (c == "ia") || (c == "ih") || (c == "iy") || (c == "oh") || (c == "ow") || (c == "oy") || (c == "ua") || (c == "uh") || (c == "uw") || (c == "th") || (c == "dh") || (c == "sh") || (c == "zh") || (c == "ch") || (c == "jh") || (c == "ng") || (c == "hh") ||(c == "ph") || (c == "qu")) {
-
}
Well I'm not sure what's wrong but you are missing an operator towards the end of the line. Ah but DeMan has just got in there first with a post before me.
Sorry Parker (It was late and I glanced at your name, my bad!!)
Line 47 also has a missing or -
-
else if ((c == "aa") || (c == "ae") || (c == "ah") || (c == "ao") || (c == "aw") || (c == "ax") || (c == "ay") || (c == "ea") || (c == "eh") || (c == "er") || (c == "ey") || (c == "ia") || (c == "ih") || (c == "iy") || (c == "oh") || (c == "ow") || (c == "oy") || (c == "ua") || (c == "uh") || (c == "uw") || (c == "th") || (c == "dh") || (c == "sh") || (c == "zh") || (c == "ch") || (c == "jh") || (c == "ng") || (c == "hh") ||(c == "ph") || (c == "qu")) {
-
}
It has a missing what??
I'm trying my best to not copy the code that you give me, but to learn and make my own code from the examples that you guys set.
And its fine about the name .
an "or" operator - one of these: ||
an "or" operator - one of these: ||
OH!!!
Now that you point it out, it has become extremely clear.
And, it works perfectly.
Next Time, I'll proofread my work more throughly, thanks guys.
Oh, by the way, the function for pig latin is free to use by anybody who wants to use it, just give me credit ;).
What exactly is pig latin? Forgive me for my ignorance.
What exactly is pig latin? Forgive me for my ignorance.
No problem.
According to Wikipedia, Pig Latin was actually originally a made up language made up by inmates to fool guards. Now, it is mostly for use on playgrounds, becasue it has become common knolage and children find it fun. You should look it up.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: LRW |
last post by:
I'm not exactly sure how to even ask the question, and I know my terminology
is not good as I'm a SQL beginner, but, here goes.
I need to find a way to make an if statement within an array...or,...
|
by: Bartosz Wegrzyn |
last post by:
I am trying to upload images using either exec command.
The file is uploaded ok.
My script:
<html>
<head>
<title>Picture Upload Page</title>
<?php
if ($_POST=="upload") {
|
by: Scott Beavers |
last post by:
I'm trying to create a form in Excel to sort from the form and take the data
to another worksheet.
I am very new to this and any help would be appreciated.
I have a value in a cell that will...
|
by: M Wells |
last post by:
Hi All,
Just wondering if anyone can tell me if you can test for multiple
conditions as part of an "IF" statement in T-SQL in SQL Server 2000?
ie something like:
IF @merr = 1 or @merr=2...
|
by: Mark Morton |
last post by:
I'm writing an if statement for a UK credit card form validation
script. Users who specify that their card is Switch need to enter
either the issue number or the 'valid from' date.
I'm trying to...
|
by: David Cleaver |
last post by:
Hello all,
I was wondering if there were some sort of limitations on the "if"
statement? I'm writing a program which needs to check a bunch of
conditions all at the same time (basically). And...
|
by: Jacob.Bruxer |
last post by:
Hi,
I'm pretty new to Visual Basic and programming in general. I want to
know if it's possible to create an If statement that asks if a value is
an integer. If it's an integer it does one thing,...
|
by: marsarden |
last post by:
write code like:
int main(void)
{
int a=10;
if(a<20)
{}
}
Compiler ok on dev-cpp . don't we have to add a ";" after if
|
by: ibukhari |
last post by:
Hi,
I have a question regarding a optimization in if statement in C. Which one is more optimised in the following. Is the assembly generated by compiler is differant for both cases? Is the machine...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
| |