Devam Ediyor

Basic Java Coding - 15$ - 6 Hours Deadline

Exercise 4

Implement and run the following code snippet. This program generates ten random integers. Note that the numbers range between a very large negative number and very large positive number. This might not be that useful for many applications. Often we want to generate uniformly distributed random numbers between two limits/bounds.

Random rand = new Random();

for(int i=0;i<10;++i)


[login to view URL]([login to view URL]());


Modify, run and test the program as follows:

a) Generate random integers between -100 and +100 (inclusive).

b) Generate random integers between limits (pre-specified) a and b.

c) Generate random doubles between zero and one.

d) Generate random doubles between limits (pre-specified) a and b.

Make sure your programs cater for any error conditions, e.g. where b > a.

Exercise 5: Reading Data

Copy-paste the text in Appendix A, to create a text file called “the art of [login to view URL]”. Write a program that takes as a parameter the name of the file and returns an integer containing the number of words in that file. The text in Appendix A contains 558 words.

Test your program on several of your own test files and the file you have created from the Appendix.

Note that you can use Microsoft Word to count the number of words in a text file.

Exercise 6: Writing Data

a) Complete the following code that takes as input a number n and a text string filename and writes n lines to the file where each line is of the form: i: sqrt(i).

i should take all values from 1 to n.

Follow the example below:

public static void main(String args[]) throws IOException


writefile(5,"c:\\temp\\[login to view URL]" );


public static void writefile(int n, String filename)throws IOException{

FileWriter writehandle = new FileWriter(filename);

//complete the rest of the code to write in the file


The contents of the file should look like the following after running your code:

1 : 1.0

2 : 1.4142135623730951

3 : 1.7320508075688772

4: 2.0

b) Now modify the writefile method so that the contents of the files will look like that:

That is, the first square root is to one decimal place, the second is to two decimal places and the third is to three decimal places.

1: 1.0

2: 1.41

3: 1.732

4: 2.0000

Exercise 7: Searching for the Longest Word

Write a Java program to find all of the longest word in a list of words entered by the user assuming that the user finishes entering the words in the list when s/he enters the word “done”.









Result: resource









Result: cat, dog, red

 The code in the main method will ask the user to enter the list of words.

 Then, the code responsible about finding the longest word/s in the list should be written in a user-defined method named (Longest_Word) that is called from the main method and returns the longest word to the main method

 In case there is more than one word has the same length as the longest word (e.g. example 2 above, then the user-defined method will return all the words separated by a comma)

Beceriler: Java, Yazılım Mimarisi, JavaScript, PHP

Daha fazlasını gör: input dialog basic java, basic java sip phone, basic java code student, convert visual basic java symbian, visual basic java dot net sql, java coding add image, creating basic java sudoku, deliver small project assignments java coding, basic java application car dealer, basic java sudoku help, java coding cgpa, java coding converting money, thesis comparing visual basic java, develop java coding want millionaire, mini project airline reservation using basic java, java coding patient management system, basic java program needs gui, basic java coding, 6 hours a day coding

İşveren Hakkında:
( 9 değerlendirme ) London, United Kingdom

Proje NO: #24110236

Bu iş için 1 freelancer ortalamada $30 teklif veriyor


Hello, I am a computer science grad (Master's degree) and a Java expert with 5 years of experience. I can confidently help you with your task in less than 6 hours but for 30usd. I have a track record of delivering Daha Fazla

$30 USD in 7 gün içinde
(59 Değerlendirme)