473,382 Members | 1,512 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

conversion of language.

2
AmeriCanadian
Americans spell differently from Canadians. Americans write "neighbor" and "color" while Canadians write "neighbour" and "colour”. Write a program to help Americans translate to Canadian. Your program should interact with the user in the following way. The user should type a word (not to exceed 64 letters) and if the word appears to use American spelling, the program should echo the Canadian spelling for the same word. If the word does not appear to use American spelling, it should be output without change. When the user types "quit!" the program should terminate.
The rules for detecting American spelling are quite naive: If the word has more than four letters and has a suffix consisting of a consonant followed by "or", you may assume it is an American spelling, and that the equivalent Canadian spelling replaces the "or" by "our". Note : you should treat the letter "y" as a vowel.
Keyboard input and screen output is expected.
Sample session. User input in italics.
Enter words to be translated:
color
colour
for
for



Expand|Select|Wrap|Line Numbers
  1. {  int f,x;
  2.    string s1,e;
  3.    do{
  4.    cout<<"enter your word:"<<endl;
  5.    cin>>s1;
  6.    f=s1.find("or");
  7.    x=s1.length();
  8.    if(x<=3 )
  9.     cout<<s1<<endl;
  10.  
  11. else {
  12.    e=s1.erase(0,f-2);
  13.    cout<<s1.substr(0,1+1)+ ("our")<<endl;
  14.   }}
  15.    while(s1!="quite");
  16. return 0;}
  17.  
Sep 28 '13 #1
5 1366
Nepomuk
3,112 Expert 2GB
So... what is your question?
Sep 29 '13 #2
Riana
2
of course my question....my qoustion is "what's wrong with my prograaaaaammmmmm???"
Sep 30 '13 #3
Cmaza
16
What about words like "Flour" and "Devour"? Your logic is fairly sound, given that with the American standardisation of English, most -our words were changed to -or words. However, unfortunately, in any given natural language - especially English - there are always exceptions to the rules.

Best thing you could probably do here is hard-code for the more commonly encountered exceptions, and include a disclaimer in your documentation with a contact method for in the event that future problems are found (because for anything to do with language, there'll always be future problems, especially as language changes frequently; many words I was taught back in my school years are spelled different today).

( Additional challenge - In this post, there are two very small clues that could indicate which dialect of English is my native dialect. I'm curious if anyone can spot them. )
Sep 30 '13 #4
Nepomuk
3,112 Expert 2GB
@Riana I don't know. What is or isn't it doing? Why do you believe that something is wrong at all? We will be happy to help you fix your problems but we won't go looking for them.

@Cmaza I'm pretty sure this is a homework task and it says in the description "The rules for detecting American spelling are quite naive". If this were ever used outside of the programming course it's probably for, I'd agree though. ^^
Sep 30 '13 #5
weaknessforcats
9,208 Expert Mod 8TB
Build a dictionary.

You will need an American->Canadian and also a Canadian->American. Data base designers would see this as one database with two indexes.

So, the user enters a word, you look it up in the dictionary and get the word in the other language. There's no parsing of the input trying to make color into colour.
Oct 4 '13 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Russell Reagan | last post by:
In a newer version of a chess program I am writing, I have created classes that are (more or less) drop in replacements for things that used to be plain old integer or enumerated variables (colors,...
21
by: Nitin Bhardwaj | last post by:
Hi all, It is said that C++ is a strongly typed language and thus a type-safe language (unlike C). So how does one explain the following behaviour : int main(void) { char *p = NULL; p = "A...
9
by: Tanmoy Bhattacharya | last post by:
Hi, This is a question about whether I am right that a particular syntactic sugar is missing in C++. Let me explain with an example. Let us say I have a class for complex numbers, and I want...
5
by: Scott Nonnenberg [MSFT] | last post by:
This is really exciting stuff. We'll see you there! It might be a good idea to do some background reading before you show up. :0) C# 3.0: http://msdn.microsoft.com/vcsharp/future/ The LINQ...
0
by: Charles Atwood | last post by:
I am trying to use the Java Language Conversion Assistant 2.0 with Visual Studio .NET 2003 on Windows 2000 Server SP4 and .NET framework 1.1 to convert some java files to C#. I go through all the...
7
by: Sanjay Kedare | last post by:
Hi, I am evaluating various alternatives of converting Delphi (Ver 4.0) screens to C# screens. Are there any tools available for such conversion? if yes how much conversion do they achieve? The...
47
by: rawCoder | last post by:
Hi, Just wanted to know if there is any speed difference between VB conversion Keywords like CInt, Clng, CStr, CDbl, CBool etc. ..NETs Convert.To<...> methods. And which is better to be...
669
by: Xah Lee | last post by:
in March, i posted a essay “What is Expressiveness in a Computer Language”, archived at: http://xahlee.org/perl-python/what_is_expresiveness.html I was informed then that there is a academic...
2
by: =?Utf-8?B?U2FtZWVrc2hh?= | last post by:
Suppose there are 2 classes A and B with a int parameter called 'val' in each. Both of them provide a public constructor with int type parameter. Suppose class A provides a explicit conversion...
9
by: arunmib | last post by:
hi all, How can I convert an Integer (int data type) and an unsigned char data type to a quadword? I want to know the conversion mechanism.... Advance thanks for the help.
1
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...
0
isladogs
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
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
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.