C program simple version of blackjack following this design.
1. The basic rules of game
A deck of poker cards are used. For simplicity, we have
unlimited number of cards, so we can generate a random card without
considering which cards have already dealt. The game here is to
play as a player against the computer (the dealer). The aim of the
game is to accumulate a higher total of points than the dealer’s,
but without going over 21. The cards 2 to 10 have their face values
as points. J, Q, and K are10 points each, and the Ace is either 1
point or 11 points (player's choice). To simplify the matter, we
consider that the Ace is 11 points and we don’t have card J, Q, or
K unless you like to implement the option anyway.
a) Betting
The player first places a bet. Let’s assume the minimum bet is $10
and maximum = is $1000.
b) Each play will result in one of the following events for the player
c) The start of the game
At the start, the player and the dealer receive two cards each. The
player’s cards are normally dealt face up (displayed), while the
dealer has one face down (called the hole card) and one face up.
The best possible blackjack hand is an opening deal of an Ace with
any of the ten-point cards. This is called a "blackjack", or a
natural 21, and the player holding this automatically wins unless
the dealer also has a blackjack. If a player and the dealer each
have a blackjack, the result is a push.
d) The player’s turn
The player can keep his hand as it is (stand) or take more cards
from the deck (hit), one at a time, until either the player judges
that the hand is strong enough to go up against the dealer’s hand
and stands, or until it goes over 21, in which case the player
immediately loses (busted).
e) The dealer’s turn
The dealer turns over the hidden hole card. The dealer hits (takes more cards) or stands depending on the value of the hand. The dealer must hit if the value of the hand is lower than 17, otherwise the dealer stands.
If the dealer is busted, the player wins. Otherwise the player wins
if s/he has a higher score, loses if s/he has a lower score, or
pushes if s/he has the same score as the dealer.
Blackjack consideration is not required, unless you like to implement the option anyway. By the way, a blackjack hand beats any other hand, also those with a total value of 21 but with more cards (which is not a natural blackjack).
f) The program towards the
end
If the player won or lost, s/he must decide whether to quit or to
play another game unless the player runs out of money. Your program
should give the player an initial betting amount of $1000.00.
2. The specific design of this project
a) The main() program and its variables
You will need to decide on appropriate variables in which to store
the player's bankroll (in order to keep track of how much money or
how many points the player has), the bet at a game, and other
information. Let’s use an integer array gamerecord[] to store how
many times the player won, lost, hit a blackjack, and got busted.
(Again, blackjack is optional).
The bankroll, bet, and gamerecord[] should be kept up to date on
the player's current status. (The program calls playing() to play a
game, as discussed below. )
After each game, the program must report the result of the game:
the amount of money won or lost, the current value of the bankroll,
how many times the player won and lost, and how many times the
player hit a blackjack and got busted. (You may want to record and
report how many times the dealer got busted as well, as an
option.)
After each game (by calling playing()), the program should allow the player to continue playing until s/he chooses to quit, or until s/he runs out of money. This central program control may be done within main(), in a do-while loop: 1) call playing() to play a game; 2) check whether to play again. We will add some more components later.
b) “Dealing” the card: the dealing() function
A separate dealing() function will be used to
generate a card number. You may want to implement and double check
this function first. You will use a random number generator. The
random number generator needs to be seeded with the current time at
the beginning of the main program. The possible random values
generated are 1 to 10 (or 13 if J, Q, and K are considered),
representing the cards’ face values. This function will return the
number generated. The return value 1 represent the Ace’s face value
(and the return value 11, 12, and 13 are J, Q, and K’s face value,
respectively.) A large random number n can be converted to
a value between 1 to 13 by: (1 + n%13).
c) “Playing” the game: playing() function
A second function playing() will be used to play a
single game until the player either wins or loses a bet, based upon
the rules given above. This function should get a bet, modify the
current amount of the player's bank roll according to the game
result, modify the gamerecord array values of the player won or
lost, and the player hit the blackjack or got
busted. These values are returned through function
parameters by address passing in playing().
Within the function, the player is asked to place a bet (10 to 1000
within the bankroll amount), so the corresponding value is read
from the keyboard. The system (dealer) then "deals the cards"
(simulated by calling the function dealing(), one card at a time).
After each dealing, this function should report the card values,
except the dealer’s hole card. The function should have two
variables to store the player and the dealer’s scores. Remember
face value 1 represents score 11 (or 1 if you want to be more
complete as an option, and 11, 12, or 13 represents score 10).
The player can keep his hand as it is (stand) or take more cards
from the deck (hit), one at a time, until either the player judges
that the hand is strong enough to go up against the dealer's hand
and stands, or until it goes over 21, in which case the player
immediately loses the bet.
The dealer turns over his hidden hole card by displaying the hold
card face value, and starts the game process automatically until
the dealer wins or loses.
d) "Ending" and "Beginning" of the game
This part is implemented after you have done your programming as
described above already.
You need a separate function ending() to do the following: you should report the current value of the bank roll, how many times the player won, lost, hit a blackjack, and went busted. You need to save the above information into a text file as well.
You need a separate function beginning() to do the
following at the beginning of your program in main(): the function
will open the text file you used to save the game information for
reading if it exists, so that your game can continue from previous
played results. If the file does not exist or the bank roll has a
balance below the minimum bet, you start the game from scratch as
usual, and report “new game” or “continual game”.
So, main() includes 1) beginning(); 2) a loop: playing(); 3) ending();
In: Computer Science
how to calculate this question tep by step plz tell me A company has recorded data on the weekly sales for its product (y), the unit price of the competitor's product (x1), and advertising expenditures (x2). The data resulting from a random sample of 7 weeks follows. Use Excel's Regression Tool to answer the following questions (data set also provided in accompanying MS Excel file). Week Price Advertising Sales 1 .33 5 20 2 .25 2 14 3 .44 7 22 4 .40 9 21 5 .35 4 16 6 .39 8 19 7 .29 9 15 a. What is the estimated regression equation? Show the regression output. b. Determine whether the model is significant overall. Use α = 0.10. c. Determine if competitor’s price and advertising is individually significantly related to sales. Use α = 0.10. d. e. Based on your answer to part (c), drop any insignificant independent variable(s) and re-estimate the model. What is the new estimated regression equation? Interpret the slope coefficient(s) of the model from part (d). (
In: Statistics and Probability
Cardinal Company has determined the following standard cost data necessary to manufacture one unit of its primary product:
Direct Materials….. (6 pounds @ $20)
Direct Labor…………. .(8 hours @ $15)
During 20X1, Cardinal produced only 1 unit of product. This unit required 7 pounds of direct material (a total of 8 pounds were purchased at a cost of $18 per pound). In addition, total payroll costs for direct labor during 20X1 were $130 (10 hours @ $13 per hour).
Required:
Answer the following questions, indicating BOTH the dollar amount of each variance and whether each variance is FAVORABLE (F) or UNFAVORABLE (U).
The materials price variance was $__
The materials efficiency (usage) variance was $__
The labor rate (price) variance was $__
The labor efficiency (usage) variance was $__
The total cost of the unit completed in 20X1 and transferred from Work in Process to Finished Goods was $
In: Accounting
Mary Itzoff is a scholarship soccer player at Local University. During the summer she works at a youth all-sport camp that several of the university’s coaches operate. The sports camp runs for eight weeks during July & August. Campers come for a one-week period, during which time they live in the university’s dormitories and use the athletic fields and facilities. At the end of a week a new group of players/campers comes in.
Mary serves primarily as one of the camp soccer instructors. However, she has also been placed in charge of arranging for sheets for the beds the campers will sleep on in the dormitories. Mary has been instructed to develop a plan for purchasing and cleaning sheets each week of camp at the lowest possible cost.
Clean sheets are needed at the beginning of each week, and the campers use the sheets all week. At the end of the week campers strip their beds and place their sheets in large bin. Mary must arrange either to purchase new sheets or clean old sheets. A set of new sheets costs $10.00. A local laundry has indicated it will clean a set of sheets for $4.00. Also a couple of Mary’s friends have asked her to let them clean some of the sheets. They have told her they will only charge $2.00 for each set of sheets. However, the laundry will provide cleaned sheets in a week, Mary’s friends can only deliver cleaned sheets in two weeks. They are going to summer school and plan to launder the sheets at night in a neighbourhood laundromat.
The following number of campers have registered during each of the eight weeks will operate
|
Week |
Registered Campers |
||
|
1 |
115 |
||
|
2 |
210 |
||
|
3 |
250 |
||
|
4 |
230 |
||
|
5 |
260 |
||
|
6 |
300 |
||
|
7 |
250 |
||
|
8 |
190 |
Based on the discussions with camp administrators from previous summers and on some old camp records and receipts, Mary estimates that about 20% of the cleaned sheets that are returned will have to be discarded and replaced. The campers spill food and drinks on the sheets, and sometimes the stains will not come out of the sheets during cleaning. Also, the campers occasionally tear the sheets or the sheets can be torn at the cleaners. In either case, when sheets come back from the cleaners and are put on the beds, 20% are taken off and thrown away.
At the beginning of the summer, the camp has no sheets available, so initially sheets must be purchased. Sheets are thrown away at the end of the summer.
Mary’s major at Local University is operations management, and she wants to develop a plan for purchasing and cleaning sheets using linear programming. Help Mary formulate a linear programming model for the problem, and solve it using Excel.
In: Operations Management
1. Use the following production function to answer the questions below where labor is measured in workers per day, capital is measured in sewing machines available per day, and output is measured in jeans per day.
Labor
1 2 3 4 5 6 7 8
Capital
1 15 34 44 48 50 51 51 47
2 20 46 64 72 78 81 82 80
3 21 50 73 83 92 99 103 103
Suppose a firm had three sewing machines and could vary only the amount of labor input.
a. Graph the production function for jeans given three sewing machines.
b. Compute and graph the marginal product curve on a separate diagram.
c. What amount of labor is associated with the point of diminishing returns?
d. After the point of diminishing returns is reached, is total
output still increasing when marginal product begins
to diminish? In other words, does diminishing
returns imply diminishing output? Explain your
answer.
e. When total output stops increasing, what is the value of marginal product?
In: Economics
The comparative balance sheets for 2018 and 2017 are given below
for Surmise Company. Net income for 2018 was $88 million.
| SURMISE COMPANY Comparative Balance Sheets December 31, 2018 and 2017 ($ in millions) |
||||||||
| 2018 | 2017 | |||||||
| Assets | ||||||||
| Cash | $ | 32 | $ | 39 | ||||
| Accounts receivable | 94 | 115 | ||||||
| Less: Allowance for uncollectible accounts | (30 | ) | (6 | ) | ||||
| Prepaid expenses | 25 | 20 | ||||||
| Inventory | 147 | 130 | ||||||
| Long-term investment | 74 | 30 | ||||||
| Land | 108 | 108 | ||||||
| Buildings and equipment | 432 | 290 | ||||||
| Less: Accumulated depreciation | (149 | ) | (116 | ) | ||||
| Patent | 29 | 31 | ||||||
| $ | 762 | $ | 641 | |||||
| Liabilities | ||||||||
| Accounts payable | $ | 23 | $ | 50 | ||||
| Accrued liabilities | 4 | 24 | ||||||
| Notes payable | 52 | 0 | ||||||
| Lease liability | 134 | 0 | ||||||
| Bonds payable | 69 | 145 | ||||||
| Shareholders’ Equity | ||||||||
| Common stock | 73 | 50 | ||||||
| Paid-in capital—excess of par | 269 | 205 | ||||||
| Retained earnings | 138 | 167 | ||||||
| $ | 762 | $ | 641 | |||||
Required:
Prepare the statement of cash flows of Surmise Company for the year
ended December 31, 2018. Use the indirect method to present cash
flows from operating activities because you do not have sufficient
information to use the direct method. You will need to make
reasonable assumptions concerning the reasons for changes in some
account balances. A spreadsheet or T-account analysis will be
helpful. (Hint: The right to use a building was acquired with a
seven-year lease agreement. Annual lease payments of $8 million are
paid at January 1 of each year starting in 2018.) (Enter
your answers in millions (i.e., 10,000,000 should be entered as
10). Amounts to be deducted should be indicated with a minus
sign.)
In: Accounting
A study regarding the relationship between age and the amount of pressure sales personnel feel in relation to their jobs revealed the following sample information. At the 0.01 significance level, is there a relationship between job pressure and age?
| Degree of Job Pressure | |||
| Age (years) | Low | Medium | High |
| Less than 25 | 20 | 18 | 22 |
| 25 up to 40 | 50 | 46 | 44 |
| 40 up to 60 | 58 | 63 | 59 |
| 60 and older | 34 | 43 | 43 |
State the decision rule. Use 0.01 significance level. (Round your answer to 3 decimal places.)
H0: Age and pressure are not related.
H1: Age and pressure are related.
Compute the value of chi-square. (Round your answer to 3 decimal places.)
What is your decision regarding H0?
In: Statistics and Probability
Problem 6-5A (Part Level Submission)
You are provided with the following information for Najera Inc.
for the month ended June 30, 2017. Najera uses the periodic method
for inventory.
|
Date |
Description |
Quantity |
Unit Cost or |
|||||
| June | 1 | Beginning inventory | 40 | $40 | ||||
| June | 4 | Purchase | 135 | 44 | ||||
| June | 10 | Sale | 110 | 70 | ||||
| June | 11 | Sale return | 15 | 70 | ||||
| June | 18 | Purchase | 55 | 46 | ||||
| June | 18 | Purchase return | 10 | 46 | ||||
| June | 25 | Sale | 65 | 75 | ||||
| June | 28 | Purchase | 30 |
50 |
||||
Calculate gross profit rate under each of the following methods.
(1) LIFO. (2) FIFO. (3) Average-cost. (Round answers to
1 decimal place, e.g. 51.2%.)
In: Accounting
Integrate the following values of y from x = 0 to x = 130 using (a) The midpoint rule using intervals of [0 10], [10 30], [30 70], and [70 130] (b) The trapezoid rule using the same intervals (c) Simpson’s rule using the same intervals
x y
0 6
5 12
10 18
20 30
30 42
50 36
70 24
100 18
130 6
Integrate the differential equation dydt = y from t = 0 to t = 1 in one step (i.e., with a t of 1) using the Euler method, the Improved Euler method, and the classical Runge-Kutta method, which is the analog of Simpson’s rule. Assume that the initial value of y is 1. Compare your answers to the correct answer, which is exp(1) = 2.7183. You can do all the calculations with an excel spread sheet. Alternatively, you can do all the calculations by hand.
In: Statistics and Probability
| Product | Unit cost Cost | Price | Date | Product | Unit Sales | (report 2 numbers after decimal place) | ||||||||
| A1 | 56 | 61.6 | 1/1/2010 | A2 | 3 | Question 3 | What is the total cost of good sold in 1/2/2010 | |||||||
| A2 | 16 | 17.6 | 1/1/2010 | A3 | 6 | |||||||||
| A3 | 90 | 99 | 1/1/2010 | A22 | 5 | |||||||||
| A4 | 67 | 73.7 | 1/1/2010 | A52 | 32 | Question 4 | What is the total sales in 1/3/2010 | |||||||
| A5 | 29 | 31.9 | 1/1/2010 | A7 | 60 | |||||||||
| A6 | 11 | 12.1 | 1/1/2010 | A18 | 98 | |||||||||
| A7 | 5 | 5.5 | 1/1/2010 | A32 | 96 | Question 5 | What is the total profit for the whole period | |||||||
| A8 | 57 | 62.7 | 1/2/2010 | A23 | 97 | |||||||||
| A9 | 14 | 15.4 | 1/2/2010 | A91 | 52 | |||||||||
| A10 | 45 | 49.5 | 1/2/2010 | A81 | 63 | |||||||||
| A11 | 34 | 37.4 | 1/2/2010 | A7 | 98 | |||||||||
| A12 | 44 | 48.4 | 1/2/2010 | A10 | 52 | |||||||||
| A13 | 57 | 62.7 | 1/2/2010 | A53 | 22 | |||||||||
| A14 | 71 | 78.1 | 1/2/2010 | A77 | 11 | |||||||||
| A15 | 33 | 36.3 | 1/2/2010 | A95 | 23 | |||||||||
| A16 | 41 | 45.1 | 1/3/2010 | A7 | 325 | |||||||||
| A17 | 37 | 40.7 | 1/3/2010 | A10 | 45 | |||||||||
| A18 | 52 | 57.2 | 1/3/2010 | A33 | 74 | |||||||||
| A19 | 4 | 4.4 | 1/3/2010 | A24 | 52 | |||||||||
| A20 | 33 | 36.3 | 1/3/2010 | A91 | 20 | |||||||||
| A21 | 39 | 42.9 | 1/3/2010 | A60 | 10 | |||||||||
| A22 | 8 | 8.8 | 1/3/2010 | A75 | 10 | |||||||||
| A23 | 89 | 97.9 | 1/3/2010 | A85 | 120 | |||||||||
| A24 | 3 | 3.3 | 1/4/2010 | A24 | 100 | |||||||||
| A25 | 7 | 7.7 | 1/4/2010 | A3 | 150 | |||||||||
| A26 | 60 | 66 | 1/4/2010 | A10 | 130 | |||||||||
| A27 | 31 | 34.1 | 1/4/2010 | A11 | 55 | |||||||||
| A28 | 43 | 47.3 | 1/4/2010 | A65 | 69 | |||||||||
| A29 | 23 | 25.3 | 1/4/2010 | A51 | 95 | |||||||||
| A30 | 68 | 74.8 | ||||||||||||
| A31 | 20 | 22 | ||||||||||||
| A32 | 35 | 38.5 | ||||||||||||
| A33 | 77 | 84.7 | ||||||||||||
| A34 | 35 | 38.5 | ||||||||||||
| A35 | 75 | 82.5 | ||||||||||||
| A36 | 22 | 24.2 | ||||||||||||
| A37 | 9 | 9.9 | ||||||||||||
| A38 | 9 | 9.9 | ||||||||||||
| A39 | 19 | 20.9 | ||||||||||||
| A40 | 29 | 31.9 | ||||||||||||
| A41 | 43 | 47.3 | ||||||||||||
| A42 | 58 | 63.8 | ||||||||||||
| A43 | 60 | 66 | ||||||||||||
| A44 | 62 | 68.2 | ||||||||||||
| A45 | 48 | 52.8 | ||||||||||||
| A46 | 56 | 61.6 | ||||||||||||
| A47 | 54 | 59.4 | ||||||||||||
| A48 | 68 | 74.8 | ||||||||||||
| A49 | 6 | 6.6 | ||||||||||||
| A50 | 2 | 2.2 | ||||||||||||
| A51 | 82 | 90.2 | ||||||||||||
| A52 | 13 | 14.3 | ||||||||||||
| A53 | 20 | 22 | ||||||||||||
| A54 | 44 | 48.4 | ||||||||||||
| A55 | 20 | 22 | ||||||||||||
| A56 | 64 | 70.4 | ||||||||||||
| A57 | 97 | 106.7 | ||||||||||||
| A58 | 87 | 95.7 | ||||||||||||
| A59 | 8 | 8.8 | ||||||||||||
| A60 | 33 | 36.3 | ||||||||||||
| A61 | 84 | 92.4 | ||||||||||||
| A62 | 77 | 84.7 | ||||||||||||
| A63 | 85 | 93.5 | ||||||||||||
| A64 | 23 | 25.3 | ||||||||||||
| A65 | 23 | 25.3 | ||||||||||||
| A66 | 39 | 42.9 | ||||||||||||
| A67 | 40 | 44 | ||||||||||||
| A68 | 94 | 103.4 | ||||||||||||
| A69 | 11 | 12.1 | ||||||||||||
| A70 | 44 | 48.4 | ||||||||||||
| A71 | 88 | 96.8 | ||||||||||||
| A72 | 39 | 42.9 | ||||||||||||
| A73 | 45 | 49.5 | ||||||||||||
| A74 | 24 | 26.4 | ||||||||||||
| A75 | 72 | 79.2 | ||||||||||||
| A76 | 13 | 14.3 | ||||||||||||
| A77 | 96 | 105.6 | ||||||||||||
| A78 | 42 | 46.2 | ||||||||||||
| A79 | 82 | 90.2 | ||||||||||||
| A80 | 37 | 40.7 | ||||||||||||
| A81 | 7 | 7.7 | ||||||||||||
| A82 | 92 | 101.2 | ||||||||||||
| A83 | 14 | 15.4 | ||||||||||||
| A84 | 18 | 19.8 | ||||||||||||
| A85 | 92 | 101.2 | ||||||||||||
| A86 | 36 | 39.6 | ||||||||||||
| A87 | 0 | 0 | ||||||||||||
| A88 | 8 | 8.8 | ||||||||||||
| A89 | 73 | 80.3 | ||||||||||||
| A90 | 85 | 93.5 | ||||||||||||
| A91 | 83 | 91.3 | ||||||||||||
| A92 | 48 | 52.8 | ||||||||||||
| A93 | 63 | 69.3 | ||||||||||||
| A94 | 28 | 30.8 | ||||||||||||
| A95 | 34 | 37.4 | ||||||||||||
| A96 | 16 | 17.6 | ||||||||||||
| A97 | 35 | 38.5 | ||||||||||||
| A98 | 79 | 86.9 | ||||||||||||
| A99 | 44 | 48.4 | ||||||||||||
| A100 | 53 | 58.3 | ||||||||||||
In: Finance