Write the following programs from Chapters 2 in your book and get them to work.
Three men who had a monkey bought a pile of mangoes. At night one of the men came to the pile of mangoes while the others slept and, finding that there was just one more mango than could be exactly divided by three, tossed the extra mango to the monkey and took away one third of the remainder. Then he went back to sleep.
Presently another of them awoke and went to the pile of mangoes. He also found just one too many to be divided by three so he tossed the extra one to the monkey, took one third of the remainder, and returned to sleep.
After a while the third rose also, and he too gave one mango to the monkey and took away the whole number of mangoes which represented precisely one third of the rest.
Next morning the men got up and went to the pile. Again they found just one too many, so they gave one to the monkey and divided the rest evenly. What is the least number of mangoes with which this can be done?
You are an archaeologist that has just unearthed a long-sought triplet of ancient treasure chests. One chest is plated with silver, one with gold, and one with bronze. According to legend, one of the three chests is filled with great treasure, whereas the other two chests both house man-eating pythons that can rip your head off. Faced with a dilemma, you then notice that there are inscriptions on the chests:
Silver Chest: Treasure is in this Chest.
Gold Chest: Treasure is not in this Chest.
Bronze Chest: Treasure is not in the Gold Chest.
You know that at least one of the inscriptions is true, and at least one of the inscriptions is false. Which chest do you open?
Alicia, Betty, and Carol went on a vacation. One went to Amsterdam, one went to Bombay, and one went to Cairo. Only one of the following four statements is true.
Translate the following ASCII codes into strings of characters by interpreting each group of eight bits as an ASCII character. Each digit is a hexadecimal digit.
Translate the string Java is Fun! into its ASCII representation and give your answer in hexadecimal digits. Remember even spaces have an ASCII representation.
Assume that int a = 1 and double d = 1.0 and that each expression is independent. What are the resuls of the following expressions?
int m = 1; int n = ~m; System.out.println (n);
int w = 4; int z = 2; z = 2 + 2 * ++w; System.out.println (z);
int ax = 30; int bx = ax << 3; System.out.println (ax + " " + bx);
int x = 10; int y = 20; System.out.println (x % y > y % x); System.out.println (x / y > y / x);
int x = 3; int y = 7 / 2; int z = (x > y) ? (x < y) ? 1 : 2 : 3; System.out.println (y + " " + z);
boolean b = true; boolean oldB = b; b = (b == false); System.out.println (b == oldB);Will the output be different if b was initialzed to false?