3. Write the code to print the No. 50 Fibonacci number. (2 points) 4. A homophone is one of two or more words that are pronounced alike but are different in meaning or spelling; for example, the words "two", "too", and "to". Write a Java program that uses HashMap to find the most words that has the same homophones and return the count of the number of words. (2 points)

Respuesta :

Answer:

Answers explained below

Step-by-step explanation:

SOLUTION 3

//Till 50 numbers

import java.util.ArrayList;

import java.util.LinkedList;

public class Driver {

public static void main(String[] args) {

//Upto 50

int num = 50, x = 0, y = 1;

 

System.out.print("Till number " + num + ": ");

for (int i = 1; i <= num; ++i)

{

System.out.print(x + " + ");

int addition = x + y;

x = y;

y = addition;

}

}

}

Solution 4:

import java.util.ArrayList;

import java.util.Arrays;

import java.util.HashMap;

import java.util.LinkedList;

public class Driver {

public static void main(String[] args) {

// Some homophonic words are:

/*

* ate, eight

* bare, bear

* buy, by, bye

* eye, I

*

*/

// Creating Hashmap

HashMap<String, String[]> homo = new HashMap<String, String[]>();

homo.put("ate", new String[] { "ate", "eight" });

homo.put("bare", new String[] { "bare", "beare" });

homo.put("buy", new String[] { "buy", "bye", "by" });

homo.put("eye", new String[] { "eye", "I" });

for (String i : homo.keySet()) {

int count=homo.get(i).length;

System.out.println(i+" has "+count+" homophone words");

}

}

}