In: Mechanical Engineering
The HeadStart runs a day camp for 6- to 10- year olds during the summer. Its manager is trying to reduce the center's operating costs to avoid having to raise the tuition fee. The manager is currently planning what to feed the children for lunch. She would like to keep costs to a minimum, but also wants to make sure she is meeting the nutritional requirements of the children. She has already decided to go with peanut butter and jelly sandwiches, and some combination of apples, milk, and/or cranberry juice. The nutritional content of each food choice and its cost are given in the table below:
| Bread | Peanut Butter | Jelly | Milk | Juice | ||
| (slice) | (tbsp) | (tbsp) | Apples | (cup) | (cup) | |
| Unit Cost | $0.06 | $0.05 | $0.08 | $0.35 | $0.20 | $0.40 |
| Nutritional Data | ||||||
| Calories from Fat | 15 | 80 | 0 | 0 | 60 | 0 |
| Calories | 80 | 100 | 70 | 90 | 120 | 110 |
| Vitamin C (mg) | 0 | 0 | 4 | 6 | 2 | 80 |
| Fiber (g) | 4 | 0 | 3 | 10 | 0 | 1 |
The nutritional requirements are as follow. Each child should receive between 300 and 500 calories, but no more than 30% of these calories should come from fat. Each child should receive at least 60 milligrams (mg) of vitamin C and at least 10 grams (g) of fiber.
To ensure tasty sandwiches, the manager wants each child to have a minimum of 2 slices of bread, 1 tablespoon (tbsp) of peanut butter, and 1 tbsp of jelly, along with at least 1 cup of liquid (milk and/or cranberry juice).
The manager would like to select the food choices that would minimize cost while meeting all these requirements.
Formulate and solve a linear programming model for this problem on a spreadsheet.
a) How many ounces of each type of food are included in one serving of the lunch? (Round to three decimals)
| Bread | Peanut Butter | Jelly | Apples | Milk | Juice | |
| (slice) | (tbsp) | (tbsp) | (cup) | (cup) | ||
| Diet (ounces) |
b) How many calories from fat are in one serving of the lunch? (Round to three decimals)
c) What is the total cost per serving of the lunch? (Round to two decimals) $
In: Math
A train runs between 2 stations, 2 km apart at a average speed of 40kmph. The train is made to run according to the quadrilateral speed time curve. If the max speed is to be limited to 60 kmph, acceleration to 2 kmphps, coasting retardation to 0.15 kmphps and the braking retardation to 3 kmphps. Determine the duration of acceleration, coasting and braking.
In: Electrical Engineering
In: Operations Management
Jones and Smith are neighbors. Jones runs a marijuana shop out of his home. Smith, a doctor, sees patients at his home. Jones makes an annual profit of $1.5 million from operating his marijuana business. Smith earns $750,000 annually from his medical practice, but he would earn $1.2 million without the disruption caused by Jones’marijuana selling activities.
(a) Suppose the law imposes no restriction on what a homeowner may do in his home. What would the outcome be, as predicted by Coase?
(b) Suppose the law requires that one’s neighbors consent to what a homeowner does in his home. What would the outcome be, as predicted by Coase?
(c) How optimal would the outcome be in case (a) and case (b)?
(d) What are transactions costs?
(e) How might the presence of transactions costs affect Coase’s analysis?
(f) What does Coase see as the role of government in this case?
( Please type all this answer,do not handwriting,thanks!)
In: Economics
A child m = 30 kg runs at vi = 5 m/s tangentially to a small playground merry-go-round, aiming at the edge with idea of jumping on and spinning around. The merry-go-round has mass 80 kg, radius 1m, and can be modeled as a thin solid disk.
1. What is the angular speed of the merry-go-round after the child jumps on?
2. After the merry-go-round turns through 270◦ , the child jumps off the merry-go-round radially and tumbles away at vf = 0.75 m/s. What is the angular speed of the merry-go-round after the child jumps off?
3. What force was applied to allow the child to change his or her linear momentum (comparing before and after interacting with the merry-go-round)?
In: Physics
*****************PLEASE PROVIDE THE CODE IN RACKET PROGRAMMING LANGUAGE ONLY AND MAKE SURE CODE RUNS ON THE WESCHEME IDE*************
Write a tail-recursive Racket function "kept-short-rec" that takes an integer and a list of strings as parameters and evaluates to an integer. The resulting integer should be the number of strings on the original list whose string length is less than the integer parameter. For example, (kept-short-rec 3 '("abc" "ab" "a")) should evaluate to 2 because there are only 2 strings shorter than 3.
Your solution must be tail-recursive. Recall that a function is tail-recursive if it is recursive and every recursive call has no work to be done after the call completes. Note: (string-length s) evaluates to the length of string s.
(define (kept-short-rec-helper acc n xs)
(if (empty? xs)
???
(if (< (string-length (first xs)) n)
???
???))
(define (kept-short-rec n xs)
(kept-short-rec-helper ??? n xs))
In: Computer Science
*****************PLEASE GIVE THE CODE IN RACKET PROGRAMMING ONLY AND MAKE SURE THE CODE RUNS ON WESCHEME IDE***************
Write a recursive Racket function "keep-short-rec" that takes an integer and a list of strings as parameters and evaluates to a list of strings. The resulting list should be all of the strings from the original list, maintaining their relative order, whose string length is less than the integer parameter. For example, (keep-short-rec 3 '("abc" "ab" "a")) should evaluate to '("ab" "a") because these are the only strings shorter than 3. Your solution must be recursive. Note: (string-length s) evaluates to the length of string s
In: Computer Science
i am looking to add more detail into my program the runs a game of rock paper scissors
i want to include a function or way to ask the user to input their name so that it could be shown in the results at the end of a round/game.
after a round something like "Mike wins!"
i also want to output the round number when the result of for each round is outputed
Round 1: Mike Wins!
Round 2: Computer wins!
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <vector>
#include <ctime>
using namespace std;
int getCpu();
int getComputerChoice();
int getPlayerChoice();
bool isTie(int, int);
bool isPlayerWinner(int, int);
int menu();
void runGame();
int main()
{
runGame();
return 0;
}
void runGame()
{
int userChoice;
int playerChoice;
int computerChoice;
int rounds;
vector <string> winner;
do
{
winner.clear();
userChoice = menu();
if (userChoice == 1)
{
do
{
cout<<"\n Enter how many rounds to play? ";
cin>>rounds;
if(rounds % 2 == 0)
break;
else
cout<<"\n Enter a even number of rounds. \t Try
again!!";
}while(1);
for(int c = 0; c < rounds; c++)
{
playerChoice = getPlayerChoice();
computerChoice = getComputerChoice();
if (isTie(playerChoice, computerChoice))
cout << "It's a TIE!\n\n";
else if (!isPlayerWinner(playerChoice, computerChoice))
{
cout << "Sorry you LOSE.\n\n";
winner.push_back("Computer WIN!");
}
else if (isPlayerWinner(playerChoice, computerChoice))
{
winner.push_back("Player WIN!");
cout << "You WIN!\n\n";
}
}
cout<<"\n ********** Final Result (Player vs. Computer)
********** ";
for(int c = 0; c < winner.size(); c++)
cout<<"\n"<<winner[c];
}
else if (userChoice == 2)
{
do
{
cout<<"\n Enter how many rounds to play? ";
cin>>rounds;
if(rounds % 2 == 0)
break;
else
cout<<"\n Enter a even number of rounds. \t Try
again!!";
}while(1);
for(int c = 0; c < rounds; c++)
{
playerChoice = getCpu();
computerChoice = getComputerChoice();
if (isTie(playerChoice, computerChoice))
cout << "It's a TIE!\n\n";
else if (!isPlayerWinner(playerChoice, computerChoice))
{
cout << "Player 2 WIN!\n\n";
winner.push_back("Player 2 WIN!");
}
else if (isPlayerWinner(playerChoice, computerChoice))
{
cout << "Player 1WIN!\n\n";
winner.push_back("Player 1 WIN!");
}
}
cout<<"\n ********** Final Result (Computer vs. Computer)
********** ";
for(int c = 0; c < winner.size(); c++)
cout<<"\n"<<winner[c];
}
else if(userChoice == 3)
exit(0);
else
cout << "Invalid selection. Try again.\n\n";
}while(1);
}
int menu()
{
int userChoice;
cout << "\n\n Welcome to rock paper scissors" <<
endl;
cout <<"Please select a game mode" << endl;
cout << "1. Player vs. Computer" << endl;
cout << "2. Computer vs. Computer" << endl;
cout << "3. Exit" << endl;
cin >> userChoice;
return userChoice;
}
int getComputerChoice()
{
srand(time(NULL));
int randomCompNum = rand() % 3 + 1;
if (randomCompNum == 1)
{
cout << "The computer chose : Rock\n\n";
}
else if (randomCompNum == 2)
{
cout << "The computer chose : Paper\n\n";
}
else if (randomCompNum == 3)
{
cout << "The computer chose : Scissors\n\n";
}
return randomCompNum;
}
int getCpu()
{
srand(time(NULL));
int cpu = rand() % 6;
if (cpu == 1 || cpu == 4)
{
cout << "player 1 chose : Rock\n\n";
}
else if (cpu == 2 || cpu == 5)
{
cout << "player 1 chose : Paper\n\n";
}
else if (cpu == 3 || cpu == 6)
{
cout << "player 1 chose : Scissors\n\n";
}
return cpu;
}
int getPlayerChoice()
{
int myChoice;
cout<< "\n\nRock, Paper, or Scissors?\n"
<< "1) Rock\n"
<< "2) Paper\n"
<< "3) Scissors\n"
<< "Please enter your choice : \n";
cin >> myChoice;
if (myChoice == 1)
{
cout << "\nYou chose : Rock\n";
}
else if (myChoice == 2)
{
cout << "\nYou chose : Paper\n";
}
else if (myChoice == 3)
{
cout << "\nYou chose : Scissors\n";
}
return myChoice;
while (myChoice < 1 || myChoice > 3)
{
cout << "Please pick a number between 1 & 3.\n";
cin >> myChoice;
}
}
bool isPlayerWinner(int myChoice, int randomCompNum)
{
if (((myChoice == 1) && (randomCompNum == 3)) || ((myChoice
== 3) && (randomCompNum == 2)) ||
((myChoice == 2) && (randomCompNum == 1)))
{
return true;
}
else if (((randomCompNum == 3) && (myChoice == 1)) ||
((randomCompNum == 3) && (myChoice == 2)) ||
((randomCompNum == 2) && (myChoice == 1)))
{
return false;
}
return 0;
}
bool isTie(int myChoice, int randomCompNum)
{
if (myChoice == randomCompNum)
{
return true;
}
else if (myChoice != randomCompNum)
{
return false;
}
return 0;
}
In: Computer Science
I am trying to create a basic shell program in C that runs 10 commands and then quits. Only one word commands are required, like:
cal, date, ls, ps, pwd, who, quit
The part I am struggling with is passing the scanned command into my array in the child process to be executed using execvp().
Here is my code:
#include <stdio.h>
#include <string.h>
#include<stdlib.h>
#include<unistd.h>
#include<sys/types.h>
#include<sys/wait.h>
#include<readline/readline.h>
#include<readline/history.h>
#define MAX_CMD_NUMBER 10
int main()
{
int i;
char command[10];
for (i=0; i< 10; i++)
{
printf("COMMAND-> ");
fflush(stdout);
scanf("%s", command); // takes in
the user's single-string command
if (strcmp(command, "quit") ==
0)
i =
MAX_CMD_NUMBER; // terminate the loop
else
printf("Command
#%d is: %s\n", i, command);
}
printf("hello world (pid:%d)\n", (int) getpid());
int rc = fork();
if (rc < 0) {
// fork failed;
exit
fprintf(stderr, "fork
failed\n");
exit(1);
}
else if (rc == 0)
{
char *command[2];
command[0] =
strdup(command);
command[1] =
NULL;
execvp(command[0],
command);
printf("this shouldn't
print out");
}
else
{
command =
wait(NULL);
}
return 0;
}
In: Computer Science