Questions
(C++) Why does my code not continue looping? it only loops twice. Can someone take a...

(C++) Why does my code not continue looping? it only loops twice. Can someone take a look at my code so far:

#include <iostream>
#include <cmath>
#include <cstdlib>
#include <string>
#include <ctime>

using namespace std;

void cls(void);

void cls(void) {
system("cls||clear");
return;
}

int main() {
int BankBalance = 0;
char quit;
int wager = 0;
int inputWager = 0;
int sum = 0;
int diceRoll = 0;
int rollPoint = 0;
int point = 0;
int dice1 = 0;
int dice2 = 0;
char playerResponse;

srand(time(0));

cout << "Hey there buddy. Welcome to the game of Craps!!! Glad you can make it :D\n\n";
cout << "Let's start with the boring rules:\n\n ";
cout << "A player rolls two dice. each die has six faces." << endl;
cout << "These faces contain 1, 2, 3, 4, 5, and 6 spots. After the dice have come to rest, the sum of the spots on the two upward faces is calculated." << endl;
cout << "If the sum is 7 or 11 on the first throw, the player wins. if the sum is 2, 3, or 12 on the first throw (called 'craps'), the player loses (i.e. the 'house' wins)." << endl;
cout << "If the sum is 4, 5, 6, 8, 9, or 10 on the first throw, then the sum becomes the player's 'point'." << endl;
cout << "To win, you must continue rolling the dice until you 'make your point'. The player loses by rolling a 7 before making the point.\n\n";

cout << "Please enter your initial Bank Balance: $";
cin >> BankBalance;

while (cin.fail()) {
cin.clear();
cin.ignore(256, '\n');

cout << "Invalid input detected, please enter a valid amount: $";
cin >> BankBalance;
}

cout << "\nCurrent bank balance: $" << BankBalance << endl;
cout << "Total wager so far: $" << wager << endl;
cout << "Please enter your wager: $";
cin >> inputWager;

while (inputWager < 0 || inputWager > BankBalance) {
cout << "Not a valid wager!!" << endl;
cout << "Current bank balance: $" << BankBalance << endl;
cout << "Total wager so far: $" << wager << endl;
cout << "Please enter your wager: $";
cin >> inputWager;
}

wager = wager + inputWager;

//BankBalance = BankBalance - inputWager;

//sum = diceRoll;

if (sum == 7) {
cout << "\nYou lose the game!!!" << endl;

BankBalance = BankBalance - inputWager;

cout << "\nBank Balance: $" << BankBalance << endl;
cout << "Roll again? (y/n)";
cin >> playerResponse;
if (playerResponse == 'n' || playerResponse == 'N') {
cout << "PEACE!!" << endl;
return -1;
}
}
else if (sum == point) {
cout << "\nYou won the game!!" << endl;
BankBalance = BankBalance + 2*wager;
cout << "\nBank Balance: $" << BankBalance << endl;
}

dice1 = rand() % 6 + 1;
dice2 = rand() % 6 + 1;
sum = dice1 + dice2;

cout << "Sum: " << sum << " (Die 1: " << dice1 << " Die 2: " << dice2 << ")" << endl;

cout << "\n\nCurrent bank balance: $" << BankBalance << endl;
cout << "Please enter your initial wager: $";
cin >> wager;

while (wager <= 0 || wager > BankBalance) {
cout << "This is not a valid wager!!" << endl;
cout << "current bank balance: $" << BankBalance << endl;
cout << "Please enter your initial wager: $";
cin >> wager;
}

//BankBalance = BankBalance - wager;
//sum = diceRoll;

if (sum == 7 || sum == 11) {
cout << "You won the game!" << endl;

BankBalance = BankBalance + 2*wager;

cout << "\nBank Balance: $" << BankBalance << endl;
cout << "\nDo you wish to continue? (y/n)";
cin >> playerResponse;
if (playerResponse == 'n' || playerResponse == 'N') {
cout << "See ya!!" << endl;
return -1;
}
}
else if (sum == 2 || sum == 3 || sum == 12) {
cout << "Craps!!!" << endl;

BankBalance = BankBalance - wager;

cout << "\nBank Balance: $" << BankBalance << endl;
cout << "\nCONTINUE? (y/n)";
cin >> playerResponse;
if (playerResponse == 'n' || playerResponse == 'N');
cout << "Peace!!" << endl;
return -1;
}
else {
cout << "\nYou need to roll to make your point (" << sum << ")..." << endl;
//system("pause");
//point = sum;
//rollPoint(point, wager);
}

return 0;
}

In: Computer Science

Queues are often used to represent lists of things that are being processed according to the...

Queues are often used to represent lists of things that are being processed according to the order in which they arrived -- i.e. "first come, first served".  

Assignment

Write a program that simulates the minute-by-minute operation of a checkout line, such as one you might find in a retail store. Use the following parameters:

1) Customers arrive at the checkout line and stand in line until the cashier is free.

2) When they reach the front of the line, they occupy the cashier for some period of time (referred to as ServiceTime) measured in minutes.

3) After the cashier is free, the next customer is served immediately.

4) Customers arrive at the checkout line at ArrivalRate per minute. Use the function included below (randomChance()) to return the number of customers arriving in a given minute, determined randomly.

5) The line can only hold so many people, MaxLineSize, until new arriving customers get frustrated and leave the store without purchasing anything.

6) ServiceTime is determined at the point the customer reaches the cashier, and should be taken from the random interval MinServiceTime and MaxServiceTime -- use the function randomInt() provided.

7) The overall time of the simulation is SimulationTime, measured in minutes.

The program should take 6 inputs (to be read from a text file named simulation.txt, as numbers only, one per line, in this order):

- SimulationTime - total number of minutes to run the simulation (whole number).

- ArrivalRate - per-minute arrival rate of customers (a floating point number greater than 0 and less than 1). This number is the "percent chance" that a customer will arrive in a given minute. For example, if it is 0.4, there is a 40% chance a customer will arrive in that minute.

- MinServiceTime - the minimum expected service time, in minutes (whole number).

- MaxServiceTime - the maximum expected service time, in minutes (whole number).

- MaxLineSize - the maximum size of the line. If a new customer arrives and the line has this many customers waiting, the new customer leaves the store unserviced.

- IrateCustomerThreshold - nobody enjoys standing in line, right? This represents the number of minutes after which a customer becomes angry waiting in line (a whole number, at least 1). These customers do not leave, they only need to be counted.

At the end of each simulation, the program should output:

- The total number of customers serviced

- The total number of customers who found the line too long and left the store.

- The average time per customer spent in line

- The average number of customers in line

- The number of irate customers (those that had to wait at least IrateCustomerThreshold minutes)

You are free to use any STL templates as needed (queue or vector, for example).

An example input file is posted in this week's Module here.

Example Run

The output should look similar to this. This example is for the first test case in the sample file.  Your output may vary somewhat because of the randomness in the simulation. In the below case, with ArrivalRate set to 0.1, we would expect about 200 people to arrive. If we add the number of customers serviced (183) with the customers leaving (25) that gives us a number (208) which is close enough to 200 to be possible for one run.

Simulation Results
------------------
Overall simulation time:     2000
Arrival rate:                 0.1
Minimum service time:           5
Maximum service time:          15
Maximum line size:              5

Customers serviced:           183
Customers leaving:             25
Average time spent in line: 33.86
Average line length:         3.15
Irate customers                10

What to Submit

Submit your .cpp file (source code for your solution) in Canvas.

Random Functions

Use these provided functions for generating your random chance (for a customer arrival) and interval for service times.

bool randomChance(double prob) { 
    double rv = rand() / (double(RAND_MAX) + 1); 
    return (rv < prob); 
} 

int randomInt(int min, int max) { 
    return (rand() % (max - min) + min); 
} 

Before calling these functions be sure to seed the random number generator (you can do this in main()):

srand(time(0));

In: Computer Science

Mrs. S is a 49-year-old woman with end-stage cardiomyopathy. She and her husband have been restaurant...

Mrs. S is a 49-year-old woman with end-stage cardiomyopathy. She and her husband have been restaurant owners for many years. She is anorexic and finds it difficult to eat solid foods, which is emotionally distressing for her and her family. She has lost 10 lb in the past month. Mrs. S was placed on the heart transplant list 6 months ago. She has agreed to hospitalization to optimize her medical management and nutrition status.

Clinical Assessment

Mrs. S is admitted to the critical care unit. A central line has been inserted for dobutamine therapy. A nutrition assessment has been completed by the dietitian that includes recommendations for frequent, small, calorie-dense, low-sodium feedings.

Diagnostic Procedures

Mrs. S is 5 feet 2 inches tall and weighs 90 lb. Her vital signs are as follows: blood pressure of 100/60 mm Hg, heart rate of 80 beats/min (sinus rhythm), respiratory rate of 20 breaths/min, and temperature of 98.2°F. Serum laboratory findings are as follows: hemoglobin level of 8.3 g/dL, prealbumin level of 14 mg/dL, sodium level of 125 mmol/L, potassium level of 3.3 mmol/L, chloride level of 94 mmol/L, carbon dioxide concentration of 26 mEq/L, calcium level of 8 mg/dL, magnesium level of 1.5 mg/dL, and B-type natriuretic peptide concentration of 500 pg/mL.

Medical Diagnosis

Mrs. S is diagnosed with cachexia resulting from end-stage cardiomyopathy.

Questions

1. What major outcomes do you expect to achieve for this patient?

2. What problems or risks must be managed to achieve these outcomes?

3. What interventions must be initiated to monitor, prevent, manage, or eliminate the problems and risks identified?

4. What interventions should be initiated to promote optimal functioning, safety, and well-being of the patient?

5. What possible learning needs do you anticipate for this patient?

6. What cultural and age-related factors may have a bearing on the patient’s plan of care?

In: Nursing

Mary-Lou is a 75-year-old widow, who lost her husband to cancer over a year ago. Her...

Mary-Lou is a 75-year-old widow, who lost her husband to cancer over a year ago. Her family and friends have noticed that she has been very teary, has low self-esteem and has lost interest in the things she used to love such as going to bingo with her friends and gardening. Her family initially put this down to the loss of her husband and thought it would pass with time. However, they are now getting really concerned as they have noticed that her mood is not improving still. When asked by her daughter if she is sleeping well, she says she has been drinking wine every night to help her go to sleep. It makes her feel happy and relaxed. What started as one glass a night has now increased to two or three glasses a night, and she has also started drinking during the day. Her daughter has noticed that her mum’s face always appears flushed and that she has had quite a few colds lately. Mary-Lou is also losing her balance and experiencing mood swings. Her daughter is worried that she is relying too heavily on alcohol and fears that she is starting to get short-term memory loss from the alcohol consumption. She has been forgetting things such as where she put her keys, whether she turned on the washing machine, why she opened the fridge and forgetting the topic of conversation when talking with her daughter on the phone. Mary-Lou has also been getting disorientated and getting lost when she goes out on her daily walks. A neighbor rang her daughter one day to tell her that she found Mary-Lou wandering around aimlessly, and when questioned what she was doing Mary-Lou snapped and said she was trying to get home. Her daughter decided it was time to take Mary-Lou to the local GP to work out what was going on with her. After listening to the signs and symptoms Mary-Lou was experiencing, the GP diagnosed her with depression and prescribed 50 mg of Fluoxetine/Prozac daily. Based on the results of clinical and radiological assessments, the GP determined that she had early onset Alzheimer’s disease. He prescribed a cholinesterase inhibitor and gave them information on support groups and tips on what to do from here on in. He also prescribed 10 mg of Diazepam daily to help with the withdrawals from alcohol abuse.

Question 1 Based on the scenario above, you should have identified three diseases/conditions we have covered in BIOL122.

• Name two of the diseases/conditions you identified, and

• List two characteristic signs or symptoms (per disease) that you noted in Mary-Lou’s history

• Finally, explain the pathophysiology of both diseases/conditions you named (i.e., explain the changes that cause the disease and relate the typical signs and symptoms of the disease).

In: Biology

Mary-Lou is a 75-year-old widow, who lost her husband to cancer over a year ago. Her...

Mary-Lou is a 75-year-old widow, who lost her husband to cancer over a year ago. Her family and friends have noticed that she has been very teary, has low self-esteem and has lost interest in the things she used to love such as going to bingo with her friends and gardening. Her family initially put this down to the loss of her husband and thought it would pass with time. However, they are now getting really concerned as they have noticed that her mood is not improving still. When asked by her daughter if she is sleeping well, she says she has been drinking wine every night to help her go to sleep. It makes her feel happy and relaxed. What started as one glass a night has now increased to two or three glasses a night, and she has also started drinking during the day. Her daughter has noticed that her mum’s face always appears flushed and that she has had quite a few colds lately. Mary-Lou is also losing her balance and experiencing mood swings. Her daughter is worried that she is relying too heavily on alcohol and fears that she is starting to get short-term memory loss from the alcohol consumption. She has been forgetting things such as where she put her keys, whether she turned on the washing machine, why she opened the fridge and forgetting the topic of conversation when talking with her daughter on the phone. Mary-Lou has also been getting disorientated and getting lost when she goes out on her daily walks. A neighbor rang her daughter one day to tell her that she found Mary-Lou wandering around aimlessly, and when questioned what she was doing Mary-Lou snapped and said she was trying to get home. Her daughter decided it was time to take Mary-Lou to the local GP to work out what was going on with her. After listening to the signs and symptoms Mary-Lou was experiencing, the GP diagnosed her with depression and prescribed 50 mg of Fluoxetine/Prozac daily. Based on the results of clinical and radiological assessments, the GP determined that she had early onset Alzheimer’s disease. He prescribed a cholinesterase inhibitor and gave them information on support groups and tips on what to do from here on in. He also prescribed 10 mg of Diazepam daily to help with the withdrawals from alcohol abuse.

Explain the mechanism of action of two drug types Mary-Lou is prescribed with and describe how these drug actions help mitigate some of her symptoms. In your answer, make references to the pathophysiology of the relevant diseases. Explain how these drug help to mitigate her symptoms.

In: Biology

Mary-Lou is a 75-year-old widow, who lost her husband to cancer over a year ago. Her...

Mary-Lou is a 75-year-old widow, who lost her husband to cancer over a year ago. Her family and friends have noticed that she has been very teary, has low self-esteem and has lost interest in the things she used to love such as going to bingo with her friends and gardening. Her family initially put this down to the loss of her husband and thought it would pass with time. However, they are now getting really concerned as they have noticed that her mood is not improving still. When asked by her daughter if she is sleeping well, she says she has been drinking wine every night to help her go to sleep. It makes her feel happy and relaxed. What started as one glass a night has now increased to two or three glasses a night, and she has also started drinking during the day. Her daughter has noticed that her mum’s face always appears flushed and that she has had quite a few colds lately. Mary-Lou is also losing her balance and experiencing mood swings. Her daughter is worried that she is relying too heavily on alcohol and fears that she is starting to get short-term memory loss from the alcohol consumption. She has been forgetting things such as where she put her keys, whether she turned on the washing machine, why she opened the fridge and forgetting the topic of conversation when talking with her daughter on the phone. Mary-Lou has also been getting disorientated and getting lost when she goes out on her daily walks. A neighbor rang her daughter one day to tell her that she found Mary-Lou wandering around aimlessly, and when questioned what she was doing Mary-Lou snapped and said she was trying to get home. Her daughter decided it was time to take Mary-Lou to the local GP to work out what was going on with her. After listening to the signs and symptoms Mary-Lou was experiencing, the GP diagnosed her with depression and prescribed 50 mg of Fluoxetine/Prozac daily. Based on the results of clinical and radiological assessments, the GP determined that she had early onset Alzheimer’s disease. He prescribed a cholinesterase inhibitor and gave them information on support groups and tips on what to do from here on in. He also prescribed 10 mg of Diazepam daily to help with the withdrawals from alcohol abuse.

Question 1 Based on the clinical picture presented above, you should have identified three diseases/conditions we have covered in BIOL122.

• Name two of the diseases/conditions you identified, and

• List two characteristic signs or symptoms (per disease) that you noted in Mary-Lou’s history

• Finally, explain the pathophysiology of both diseases/conditions you named (i.e., explain the changes that cause the disease and relate the typical signs and symptoms of the disease).

In: Biology

Geraldine (Gerri) Bowen is a 74-year-old woman living with dementia. Her husband passed away one year...

Geraldine (Gerri) Bowen is a 74-year-old woman living with dementia. Her husband passed away one year ago. He was her primary care giver, although he had contracted for a daily caregiver to help Monday through Friday with Gerri’s activities of daily living and so that he could run errands such as banking, grocery shopping, etc. Since his death, the family (three sons and their wives) set up 24-hour care giving because Gerri wants to live at home and not in an extended care facility. Recently, Gerri had complained of abdominal discomfort and has frequent diarrhea. After some diagnostic tests (a lower GI, a CT and abdominal MRI) she was diagnosed with Stage 3 (late stage 3) colon cancer. In addition, Gerri has a right lower lobe lung lesion. The surgeon feels that it is most likely not metastasis, but a second primary cancer. The surgeon recommends palliative surgery, since Gerri will not benefit from radiation or chemotherapy. You are the nurse caring for Gerri after her colon resection and overhear the family discussing what they should be telling their mother. Gerri asks you, “no one is telling me what is going on. It’s not right. I don’t want to stay here (the hospital) I just want to be at home. I don’t like all these people around me.” You tell the oldest son that Gerri has asked questions about her condition on several occasions. He tells you that he and his brothers cannot agree whether Gerri should be told about her condition (the cancer). He advises you to tell Gerri that nothing is wrong. While two of the sons want their mother told, the third son feels it would be cruel to tell her because she isn’t completely “there”. Gerri recognizes her family and recalls the past all the time. She often has difficulty expressing her feelings and recalling the immediate past. But it is your opinion that she does understand some things.

What is the dilemma and relevant facts in this case? What ethical principles are pertinent to this case?

In: Nursing

Mary-Lou is a 75-year-old widow, who lost her husband to cancer over a year ago. Her...

Mary-Lou is a 75-year-old widow, who lost her husband to cancer over a year ago. Her family and friends have noticed that she has been very teary, has low self-esteem and has lost interest in the things she used to love such as going to bingo with her friends and gardening. Her family initially put this down to the loss of her husband and thought it would pass with time. However, they are now getting really concerned as they have noticed that her mood is not improving still. When asked by her daughter if she is sleeping well, she says she has been drinking wine every night to help her go to sleep. It makes her feel happy and relaxed. What started as one glass a night has now increased to two or three glasses a night, and she has also started drinking during the day. Her daughter has noticed that her mum’s face always appears flushed and that she has had quite a few colds lately. Mary-Lou is also losing her balance and experiencing mood swings. Her daughter is worried that she is relying too heavily on alcohol and fears that she is starting to get short-term memory loss from the alcohol consumption. She has been forgetting things such as where she put her keys, whether she turned on the washing machine, why she opened the fridge and forgetting the topic of conversation when talking with her daughter on the phone. Mary-Lou has also been getting disorientated and getting lost when she goes out on her daily walks. A neighbor rang her daughter one day to tell her that she found Mary-Lou wandering around aimlessly, and when questioned what she was doing Mary-Lou snapped and said she was trying to get home. Her daughter decided it was time to take Mary-Lou to the local GP to work out what was going on with her. After listening to the signs and symptoms Mary-Lou was experiencing, the GP diagnosed her with depression and prescribed 50 mg of Fluoxetine/Prozac daily. Based on the results of clinical and radiological assessments, the GP determined that she had early onset Alzheimer’s disease. He prescribed a cholinesterase inhibitor and gave them information on support groups and tips on what to do from here on in. He also prescribed 10 mg of Diazepam daily to help with the withdrawals from alcohol abuse.

Question 4: Based on her clinical picture and history, explain if Mary-Lou suffers from alcohol addiction. Support your answer with relevant evidence from the case study.

In: Biology

Mary-Lou is a 75-year-old widow, who lost her husband to cancer over a year ago. Her...

  1. Mary-Lou is a 75-year-old widow, who lost her husband to cancer over a year ago. Her family and friends have noticed that she has been very teary, has low self-esteem and has lost interest in the things she used to love such as going to bingo with her friends and gardening. Her family initially put this down to the loss of her husband and thought it would pass with time. However, they are now getting really concerned as they have noticed that her mood is not improving still. When asked by her daughter if she is sleeping well, she says she has been drinking wine every night to help her go to sleep. It makes her feel happy and relaxed. What started as one glass a night has now increased to two or three glasses a night, and she has also started drinking during the day. Her daughter has noticed that her mum’s face always appears flushed and that she has had quite a few colds lately. Mary-Lou is also losing her balance and experiencing mood swings. Her daughter is worried that she is relying too heavily on alcohol and fears that she is starting to get short-term memory loss from the alcohol consumption. She has been forgetting things such as where she put her keys, whether she turned on the washing machine, why she opened the fridge and forgetting the topic of conversation when talking with her daughter on the phone. Mary-Lou has also been getting disorientated and getting lost when she goes out on her daily walks. A neighbor rang her daughter one day to tell her that she found Mary-Lou wandering around aimlessly, and when questioned what she was doing Mary-Lou snapped and said she was trying to get home. Her daughter decided it was time to take Mary-Lou to the local GP to work out what was going on with her.

    After listening to the signs and symptoms Mary-Lou was experiencing, the GP diagnosed her with depression and prescribed 50 mg of Fluoxetine/Prozac daily. Based on the results of clinical and radiological assessments, the GP determined that she had early-onset Alzheimer’s disease. He prescribed a cholinesterase inhibitor and gave them information on support groups and tips on what to do from here on in. He also prescribed 10 mg of Diazepam daily to help with the withdrawals from alcohol abuse.

  2. Explain the mechanism of action of two drug types Mary-Lou is prescribed with and describe how these drug actions help mitigate some of her symptoms. In you answer, make references to the pathophysiology of the relevant diseases.

In: Biology

Mary-Lou is a 75-year-old widow, who lost her husband to cancer over a year ago. Her...

Mary-Lou is a 75-year-old widow, who lost her husband to cancer over a year ago. Her family and friends have noticed that she has been very teary, has low self-esteem and has lost interest in the things she used to love such as going to bingo with her friends and gardening. Her family initially put this down to the loss of her husband and thought it would pass with time. However, they are now getting really concerned as they have noticed that her mood is not improving still. When asked by her daughter if she is sleeping well, she says she has been drinking wine every night to help her go to sleep. It makes her feel happy and relaxed. What started as one glass a night has now increased to two or three glasses a night, and she has also started drinking during the day. Her daughter has noticed that her mum’s face always appears flushed and that she has had quite a few colds lately. Mary-Lou is also losing her balance and experiencing mood swings. Her daughter is worried that she is relying too heavily on alcohol and fears that she is starting to get short-term memory loss from the alcohol consumption. She has been forgetting things such as where she put her keys, whether she turned on the washing machine, why she opened the fridge and forgetting the topic of conversation when talking with her daughter on the phone. Mary-Lou has also been getting disorientated and getting lost when she goes out on her daily walks. A neighbor rang her daughter one day to tell her that she found Mary-Lou wandering around aimlessly, and when questioned what she was doing Mary-Lou snapped and said she was trying to get home. Her daughter decided it was time to take Mary-Lou to the local GP to work out what was going on with her. After listening to the signs and symptoms Mary-Lou was experiencing, the GP diagnosed her with depression and prescribed 50 mg of Fluoxetine/Prozac daily. Based on the results of clinical and radiological assessments, the GP determined that she had early onset Alzheimer’s disease. He prescribed a cholinesterase inhibitor and gave them information on support groups and tips on what to do from here on in. He also prescribed 10 mg of Diazepam daily to help with the withdrawals from alcohol abuse.

a) Identify and explain two pharmacokinetic factors that are characteristic of/specific to Mary- Lou’s antidepressant medication. Discuss how her age impacts the pharmacokinetics of her medication.

b) Explain what specific considerations need to be made in the present scenario, when two drugs are administered simultaneously.

In: Biology