I have some JAVA assignment , and It's really hard with me , please anyone help me out about this ,Thanks
File PDF :http://www.mediafire.com/?0grtieipgc9crro
Note:
Material Covered
if statements
loops
using String charAt(), equals() and length() methods.
Notes:
Name your files as follows: <LastName><FirstName>A2Q1.java and <LastName><FirstName>A2Q2.java. For example, LiJaneA2Q1.java is a valid name. If you wish to add a version number to your file, you may add it to the end of the file name. For example, SmithRobA2Q2V2.java is a valid name.
Follow the programming standards to avoid losing marks.
To submit the assignment you will upload your .java files using the course website. You will also copy and paste your output into a text box in the online assignment submission form. Do NOT manipulate your output in any way.
----------------------------Question 1:Question 1—Esperanto
Esperanto 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."1
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 are2:
If the word ends in .. it is a(n)...
a adjective
o or on singular noun
oj or ojn plural noun
e adverb
This means there are no exceptions in Esperanto, like how in English the plural of goose is geese and while you usually add 'ly' to the end of an adjective to make it an adverb, 'goodly' isn't an adverb.
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.
Hand-in: Save your file using the naming conventions described in the beginning of the assignment. Upload your file using the web-based hand-in tool. Also, submit the output for the following input:
komputilo
sciencon
bonege
Javo
programi
cesi
Question 2—Binary Numbers
As you may know, computers work on the binary system. In this system, numbers are written using only 0s and 1s. In this question, you’ll write a program to convert binary numbers to normal (decimal) numbers.
How are all numbers represented in 0s and 1s?
Instead of having digits 0,1,...,9, in binary, we only have digits 0 and 1.
So zero is 0, and the next number is represented by 1, but after that, we have no digit 2, so we have to represent the next number in the same way we do after we go past 9 in the decimal system: by 10.
We continue in this way: 3 in binary is 11.
Now what about 4? We can’t write 4 as 12 (because we only have 1 and 0 to work with, not 2). So we put a zero in the last position, and carry the 1. This would give 20, but again, we don’t have a digit 2, so we again carry the 1 and get 100 as the binary representation of 4.
Here are the first few numbers written in both decimal (normal) notation and binary:
decimal
1
2
3
4
5
6
7
8
9
10
11
binary
1
10
11
100
101
110
111
1000
1001
1010
1011
Suppose we have a binary number (a sequence of zeroes and ones) and we
want to convert it to a decimal number. To do this, we multiply the digit (0 or 1) in each position of the number by an increasing power of two
the further we move left. So the value of the binary number 1011001 is
1*26+0*25+1*24+1*23+0*22+0*21+1*20= 89
Program Specifications:
Write a program that takes input as an integer, interprets it as a binary number, and prints out its value of the decimal number.
Get input using Scanner.
Use integer division and remainder to extract digits from the input binary number.
Assume the user only inputs numbers with digits 0 and 1.
Use a loop so the user can continue to input binary numbers until they input -1 , then exit.
Here is a sample run of the program:
Enter a binary number:1001010
1001010 in decimal is 74.
Enter a binary number:1001111
1001111 in decimal is 79.
Enter a binary number:10000111
10000111 in decimal is 135.
Enter a binary number:-1
Programmed by [your name here].
End of processing.
Output: Use System.out for output. Follow the format of the output shown above.
Hand-in: Save your file using the naming conventions described in the beginning of the assignment. Upload your file using the web-based hand-in tool. Submit three sets of data using the following input:
1. 1000011
2. 1100100 1011
3. A binary number of your choice3
Then press -1 to quit the loop.