Answer:
count_land = count_air = count_water = 0
while True:
s = input("Enter a string: ")
if s == "xxxxx":
break
else:
if s == "land":
count_land += 1
elif s == "air":
count_air += 1
elif s == "water":
count_water += 1
print("land: " + str(count_land))
print("air: " + str(count_air))
print("water: " + str(count_water))
Explanation:
*The code is in Python
Initialize the variables
Create a while loop that iterates until a specific condition is met. Inside the loop, ask the user to enter the string. If it is "xxxxx", stop the loop. Otherwise, check if it is "land", "air", or "water". If it is one of the given strings, increment its counter by 1
When the loop is done, print the number of strings entered in the required format
Zebulon Pike, the U.S. Army officer who in 1805 led an exploring party in search of the source of the Mississippi River, sets off with a new expedition to explore the American Southwest. Pike was instructed to seek out headwaters of the Arkansas and Red rivers and to investigate Spanish settlements in New Mexico.
Answer: Null Object pattern be useful when the absence of an object can be encapsulated by other alternatives which does not have any have any effect.
Explanation:
public interface Rectangle {
double area();
double surfaceare();
boolean isNull();
}
In the code above we have a function for null object. So in the absence of an object we have encapsulated with a method of null which does not do anything. It simplifies the use of dependencies that can be undefined.
In case of collaborator the NULL object pattern makes use of the existing collaboration instead of defining a new one.
It also enable to abstract the handling of null objects from the client so that internal details of the program are not know to outsiders.
Answer:
(a) 1 to 8
(b) 1 to 6
Explanation:
A "leaf" is a node at the end of a binary tree (in other words, it has no "children"). All other nodes are "non-leaf" nodes.
The smallest number of leaves is 1. That would be a binary tree that's just a straight line; each node will have only 1 child, until you get to the last node (the leaf).
To find the largest number of leaves, we start drawing a full binary tree. A complete tree with 15 nodes has 7 non-leaf nodes and 8 leaf nodes. A full tree with 6 non-leaf nodes can have up to 6 leaf nodes.