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");
}
}
}