IN SWIFT LANGUAGE
In this lab we are going to create a game that uses all the different types of control flow operators that exist in SWIFT LANGUAGE.
The game will be a choose your own adventure game. The user will have to answer a series of questions and this will change the path of a story. This must be done by using if/else statements that are nested within other if/else statements. Your story must have four (4) different possible endings. Beyond this, you must provide some setup for the story to provide customized messages. Ask the user questions that will be used to capture details for use within the story.
Ask the user at least one question that has them choose something from a list of possible values and use a switch to set the appropriate variable.
Ask the user at least one question that results in a numeric range and use an interval switch to set another variable.
Also ask the user a binary (yes/no or true/false) question. Use the answer from this in a ternary to store another variable.
Use these variables within the output of the messages to the user in the story.
Example:
Example Program Output
Here is an example of a how the program might work...
Enter your favorite color? Pick "red", "orange", "yellow", "green", or "blue" > red Do you like apples? "Yes" or "No"? > Yes How fast can you run a mile? Enter as a decimal number. > 8.5 You are walking down the street eating some apples when a red tiger runs up and takes your lunch and then quickly runs away. Do you want to "chase" the tiger or "run away"? > run away You run away from the tiger but it is a bad idea to run from an animal. It turns and decides to try to eat you. You see a bus blocking your path up ahead. Do you "get on" the bus or "go around"? > go around There is a zoo keeper on the other side of the bus only to see a subway entrance. He captures the tiger and you are saved. The End.
But then if you ran it again it might do this...
Enter your favorite color? Pick "red", "orange", "yellow", "green", or "blue" > green Do you like apples? "Yes" or "No"? > No How fast can you run a mile? Enter as a decimal number. > 20 You are walking down the street eating some oranges when a green tiger runs up and takes your lunch and then walks away. Do you want to "chase" the tiger or "run away"? > chase The tiger runs but falls into the river. Do you "help it" or "leave it"? > help it You save the tiger and it is grateful. You have a new pet. The End.
In: Computer Science
A study examines whether there is a relationship between how long a nurse has worked at a large urban hospital and her or his job satisfaction. Job satisfaction scores were on a scale with a range from 25-50. Using the data and all of the information provided in the table below to...
(a) Calculate Pearson’s r correlation.
(b) Interpret the statistic, including two parts to your interpretation.
(c) Calculate a ‘coefficient of determination’ (r2) and interpret it.
|
Participant ID |
X=Years at hospital |
Y =Job satisfaction |
Zx |
Zy |
|
101 |
10 |
40 |
+0.58 |
+0.83 |
|
102 |
6 |
29 |
-1.19 |
-1.00 |
|
103 |
14 |
45 |
+2.35 |
+1.67 |
|
104 |
8 |
30 |
-0.31 |
-0.83 |
|
105 |
10 |
32 |
+O.58 |
-0.50 |
|
106 |
8 |
38 |
-0.31 |
+0.50 |
|
107 |
7 |
32 |
||
|
108 |
8 |
35 |
||
|
109 |
9 |
42 |
||
|
110 |
7 |
27 |
||
|
Years at job MEAN |
8.70 |
|||
|
Years at job STD.DEV. |
2.26 |
|||
|
Job sat. MEAN |
35.0 |
|||
|
Job sat. STD.DEV. |
6.0 |
In: Statistics and Probability
In: Statistics and Probability
Design a program in Java to display the following:
Car Design
Enter the car model's year: 1957
Enter the car's make: Chevy
The model year is 1957
The make is Chevy
The speed is 0
Let's see what it can do!!
The speed is,...
5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 100 105 110
115 120 125 130 135 140 145 150
STOP! STOP! Let me OUT!
The speed is,...
145 140 135 130 125 120 115 110 105 100 95 90 85 80 75 70 65 60 55
50 45 40 35 30 25 20 15 10 5 0
Whew. I'll just walk from here - thanks.
In: Computer Science
Design a program in Java to display the following:
Car Design
Enter the car model's year: 1957
Enter the car's make: Chevy
The model year is 1957
The make is Chevy
The speed is 0
Let's see what it can do!!
The speed is,...
5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 100 105 110
115 120 125 130 135 140 145 150
STOP! STOP! Let me OUT!
The speed is,...
145 140 135 130 125 120 115 110 105 100 95 90 85 80 75 70 65 60 55
50 45 40 35 30 25 20 15 10 5 0
Whew. I'll just walk from here - thanks.
In: Computer Science
A market researcher believes that brand perception of one of the company's products may vary between different groups. After interviewing 269 persons, the following data was compiled. Can we conclude that brand perception is dependent on age?
| Age | Favorable | Unfavorable | Neutral | Total |
|---|---|---|---|---|
| 1818-3030 | 45 | 8 | 7 | 60 |
| 3030-4545 | 54 | 8 | 8 | 70 |
| Over 4545 | 51 | 44 | 44 | 139 |
| Total | 150 | 60 | 59 | 269 |
Step 1 of 8:
State the null and alternative hypothesis.
Step 2 of 8:
Find the expected value for the number of particpants who are 18-30 years old and have a favorable perception of the brand. Round your answer to one decimal place.
Step 3 of 8:
Find the expected value for the number of particpants who are 30-45 years old and have a favorable perception of the brand. Round your answer to one decimal place.
Step 4 of 8:
Find the value of the test statistic. Round your answer to three decimal places.
Step 5 of 8:
Find the degrees of freedom associated with the test statistic for this problem.
Step 6 of 8:
Find the critical value of the test at the 0.1 level of significance. Round your answer to three decimal places.
Step 7 of 8:
Make the decision to reject or fail to reject the null hypothesis at the 0.1 level of significance.
Step 8 of 8:
State the conclusion of the hypothesis test at the 0.1 level of significance.
In: Statistics and Probability
Diseconomies of Scale – Sources and Possible Remedies
In: Economics
Group A:
60, 57, 53, 42, 44, 48, 54, 39, 52, 45
Group B:
50, 49, 60, 55, 43, 56, 53, 69, 49, 52
Using Wilcoxen Rank Sum test to test a difference in the medians of the two populations using
Alpha= 0.05
In: Statistics and Probability
In: Economics
Q3. During April, the following changes in the single inventory product took place: (1 mark).
April 1 Balance 1,400 units @ $24
8 Purchased 900 units @ $36
12 Purchased 700 units @ $30
24 Purchased 400 units @ $50
10 Sold 1,500 units @ $40
26 Sold 1,700 units @ $44
Calculate the COGS after each sales transaction and the ending inventory after each transaction under the following methods.
(a) FIFO.
(b) Average Cost. (round numbers to the nearest 10)
Answer:
In: Accounting