Difference between revisions of "Esperanto"
m (Update of Header information) |
m (code update) |
||
Line 86: | Line 86: | ||
public class A2Q2 | public class A2Q2 | ||
{ | { | ||
− | |||
− | |||
public static void main(String[] args) | public static void main(String[] args) | ||
{ | { | ||
Scanner kbd = new Scanner(System.in); | Scanner kbd = new Scanner(System.in); | ||
− | long binaryNumber, copyOfBinNum; // input from the user. | + | long binaryNumber, copyOfBinNum; // input from the user. |
int decimalNumber; // output value. | int decimalNumber; // output value. | ||
final int BASE = 2; // binary base. | final int BASE = 2; // binary base. | ||
− | int currDigit, currPower; | + | int currDigit, currPower; // values used in loops. |
// get input from the user. | // get input from the user. |
Revision as of 12:44, 29 March 2011
Back to the Case Studies homepage
ProblemEsperanto is a language invented in the 1880s by L. L. Zamenhof. It was invented to "create an easy-to-learn and politically neutral language that would serve as a universal second language to foster peace and international understanding." One of the benefits of designing your own language is that you can impose strict rules on the language. In this question, you will use the rules of Esperanto to identify the parts of speech of different words. The rules for identifying parts of speech in Esperanto are:
Write a program that accepts words in Esperanto, and identifies whether each is an adjective, singular noun, plural noun or adverb. Input:Use Scanner to accept input in this question. Prompt the user to input a word. If the user types in "cesi" ("quit" in Esperanto), the program should quit. Otherwise, it should accept the input and process it as a word in Esperanto. After processing the word, the user should be prompted to enter another word. Assume the user inputs the words entirely in lowercase and that all words are at least three letters long. Calculate and Output:Use System.out. for all output. Use the charAt() and length() methods to find the last (one or possibly two) characters and determine which part of speech (adverb, singular noun, plural noun or adverb) the word is. If the word is in none of the four categories, print out an error message telling the user that the part of speech cannot be identified. An execution of your program would look like this: Enter a word in Esperanto: komputilo komputilo is a singular noun. Enter a word in Esperanto: sciencon sciencon is a singular noun. Enter a word in Esperanto: cesi Programmed by [your name here]. End of processing. |
Esperanto | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
SolutionHere we put the solution. Remember to abide by the Computer Science coding standards while writing the code. | ||||||||||||
Code |