Answer:
<u> FlashCard.java</u>
- public class FlashCard {
- String Question;
- String Answer;
-
- public FlashCard(String q, String a){
- this.Question = q;
- this.Answer = a;
- }
-
- public String toString(){
- String output = "";
- output += "Question: " + this.Question + "\n";
- output += "Answer: " + this.Answer;
- return output;
- }
-
- public boolean equals(String response){
- if(this.Answer.equals(response)){
- return true;
- }
- else{
- return false;
- }
- }
- }
<u>Main.java</u>
- public class Main {
- public static void main(String[] args) {
- FlashCard card1 = new FlashCard("What is highest mountain?", "Everest");
- FlashCard card2 = new FlashCard("What is natural satelite of earth?", "Moon");
- FlashCard card3 = new FlashCard("Who is the first president of US?", "George Washington");
- FlashCard cards [] = {card1, card2, card3};
-
- for(int i=0; i < cards.length; i++){
- System.out.println(cards[i]);
- }
- }
- }
Explanation:
In FlashCard.java, we create a FlashCard class with two instance variable, Question and Answer (Line 2 - 3). There is a constructor that takes two input strings to initialize the Question and Answer instance variables (Line 5-8). There is also a toString method that will return the predefined output string of question answer (Line 10 - 15). And also another equals method that will take an input string and check against with the Answer using string equals method. If matched, return True (Line 17 -24).
In Main.java, create three FlashCard object (Line 3-5) and then put them into an array (Line 6). Use a for loop to print the object (Line 8-10). The sample output is as follows:
Question: What is highest mountain?
Answer: Everest
Question: What is natural satelite of earth?
Answer: Moon
Question: Who is the first president of US?
Answer: George Washington
First there are two groups, members and non-members, so you know that there are 4 people who are members, if you subtract 4 from ten that would mean 6 people are non-members. now, for the cost of the members would be (7.50 × 4) + (2.95 × 4) = 41.8$
for the non-member group or would be (9.75 × 6) + (3.95 ×6) = 82.2$ now add 41.8 to 82.2 which equals 124.0$ in total
Answer:
You should now be able to give IP addresses to 254 hosts. This works fine if all 150 computers are on a single network. However, your 150 computers are on three separate physical networks. Instead of requesting more address blocks for each network, you divide your network into subnets that enable you to use one block of addresses on multiple physical networks
Explanation:
Answer:
def sum_cubes(n):
if n == 1:
return 1
else:
return n * n * n + sum_cubes(n-1)
print(sum_cubes(3))
Explanation:
Create a function called sum_cubes that takes one parameter, n
If n is equal to 1, return 1. Otherwise, calculate the cube of n, and add it to the sum_cubes function with parameter n-1
If we want to calculate the cubes of the first 3 numbers:
sum_cubes(3) = 3*3*3 + sum_cubes(2)
sum_cubes(2) = 2*2*2 + sum_cubes(1)
sum_cubes(1) = 1
If you substitute the values from the bottom, you get 27+8+1 = 36