52) Metro Food Services Company delivers fresh sandwiches each morning to vending machines throughout the city. The company makes three kinds of sandwiches—ham and cheese, bologna, and chicken salad. A ham and cheese sandwich requires a worker 0.45 minutes to assemble, a bologna sandwich requires 0.41 minutes, and a chicken salad sandwich requires 0.50 minutes to make. The company has 960 available minutes each night for sandwich assembly. Vending machine capacity is available for 2,000 sandwiches each day. The profit for a ham and cheese sandwich is $0.35, the profit for a bologna sandwich is $0.42, and the profit for a chicken salad sandwich is $0.37. The company knows from past sales records that its customers buy as many ham and cheese sandwiches as the other two sandwiches combined, if not more so, but custom- ers need a variety of sandwiches available, so Metro stocks at least 200 of each. Metro manage- ment wants to know how many of each sandwich it should stock to maximize profit. Formulate a linear programming model for this problem. (USE EXCEL SOLVER) (SHOW WORK)
53. Solve the linear programming model formulated in Problem 52 for Metro Food Services Company by using the computer. (USE EXCEL SOLVER) (SHOW WORK)
a. If Metro Food Services could hire another worker and increase its available assembly time by 480 minutes or increase its vending machine capacity by 100 sandwiches, which should it do? Why? How much additional profit would your decision result in?
b. What would the effect be on the optimal solution if the requirement that at least 200 sand- wiches of each kind be stocked was eliminated? Compare the profit between the optimal solution and this solution. Which solution would you recommend?
c. What would the effect be on the optimal solution if the profit for a ham and cheese sandwich was increased to $0.40? to $0.45?
In: Computer Science
In your current business environment, or one you were in at one time, which of the four cloud computing service models do you think might be good for that company to consider? How would a change to one of the cloud computing service models change the way that company does business?
In: Computer Science
4. Define briefly the different activities of the Software lifecycle.
In: Computer Science
Project 2c (Javascript/HTML/CSS)– Mouse Chase: Create a page with a nice, shiny, pretty button on it. The button should say ‘Click to receive $10!’ However, any time the user’s mouse cursor gets over the button, the button should move to a random location on the page, making the button essentially impossible to click! However, if they do somehow manage to click the button, redirect the user to an image of a 10 trillion Zimbabwe Dollar. Finally, the background color of the page should change every 3 seconds to a random color.
In: Computer Science
Which of these is/are true about stored procedures?
A user defined stored procedure can be created in a user-defined database or a resource database
Repeatable & abstractable logic can be included in user-defined stored procedures
To call output variables in a stored procedure with output parameters, you need to declare a variables outside the procedure while invocation
Temporary stored procedures are nothing but system stored procedures provided by SQL Server
In: Computer Science
Hello,
In C#, we are creating a simple calculator that takes two operands and one operator and calculates a result. We need to include a private method to calculate the result as well as try-catch statements for exceptions. My code that i have so far is below, it executes and calculates, but there is an issue with the way i have done the method. Any help or info about my method errors would be great, Thank you!
**********************************
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace SimpleCalculator
{
/***********************************
* Displays simple calculations from the
* data the user enters.
* *********************************/
public partial class simpleCalculator : Form
{
public simpleCalculator()
{
InitializeComponent();
}
private void btnCalculate_Click(object sender, EventArgs
e)
{
/*******************************
* This method calcultes the result from the
* user entry in the operands and operaator boxes.
* *****************************/
try
{
//converts the data frm the user entry frm txt to decimal and
string.
decimal operand1 = Convert.ToDecimal(txtOperand1.Text);
decimal operand2 = Convert.ToDecimal(txtOperand2.Text);
string operator1 = Convert.ToString(txtOperator1.Text);
//method to perform the calculations.
decimal result = Calculate(operand1, operand2, operator1);
}
//the catch exceptions, will try the above code and any exceptions
will be caught by the ones below
//and throw uo a message box with an error message.
catch (FormatException)
{
MessageBox.Show("A format exception has occurred. Please check all
entries." + "\n\n",
"Entry Error");
}
catch (OverflowException)
{
MessageBox.Show("An overflow exception has occurred. Please enter
smaller values",
"Entry Error");
}
catch (DivideByZeroException)
{
MessageBox.Show("Divide-by-zero error. Please enter a non-zero
value",
"Entry Error");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message + "\n\n" +
ex.GetType().ToString() + "\n" +
ex.StackTrace, "Exception");
}
//where the calculate method is called.
private decimal Calculate(decimal operand1, decimal operand2,
string operator1)
{
//initilized the result to decimal and zero.
decimal result = 0m;
//code to check the operator1 entry and compare it to either /,
*, - or +
//then do the corresponding calculation.
if (operator1 == "/")
{
result = operand1 / operand2;
}
else if (operator1 == "*")
{
result = operand1 * operand2;
}
else if (operator1 == "+")
{
result = operand1 + operand2;
}
else if (operator1 == "-")
{
result = operand1 - operand2;
}
//code to display the reslt in the result box
txtResult.Text = result.ToString();
}
}
//code to exit form
private void btnExit_Click(object sender, EventArgs e)
{
this.Close();
}
//code to clear the result box after calculation has been performed
and the operand1 box is cleared.
private void ClearResult(object sender, EventArgs e) =>
txtResult.Text = "";
}
}
In: Computer Science
You have a rental company with properties in 3 different cities Columbus Ohio, Florida and Colorado. You are currently using Linux as your operating system to run your business. Your goal is to switch over to using a Windows operating system. Which operating system would you use and what would be the benefits of using such system?
In: Computer Science
Write a program that prompts the user to input a decimal number and outputs the number rounded to the nearest integer.
In: Computer Science
Write a C function, for example void sumOfPrime(int n), that takes a positive int n as a parameter, put all prime numbers less than n into an array, and print out the array and the sum of the numbers in that array. You can use the isPrime function above to save time.
In: Computer Science
in Java
Write a function that inputs a 4 digit year and outputs the
ROMAN numeral year
M is 1,000
C is 100
L is 50
X is 10
I is 1
Test with 2016 and 1989
In: Computer Science
Write a program that allows 2 players to play the marble game using combinations of loop and conditional statements. In the marble game, you ask the user to enter how many marbles to start with. Then, the game begins. The first player must take 1, 2 or 3 marbles. Then the second player goes and must take 1, 2 or 3 marbles. The winner is the player who takes the last marble. Allow two users to play this game and print out the winner (player #1 or player#2). Assume that both players enter valid inputs (1, 2 or 3, and they never try to take more marbles than there are in the pile.)
In: Computer Science
java
In one program, write 3 separate functions, and use them.
1) Write the function body for each:
int squareInteger s( int x)
double squareDouble( double d)
float squareFloat ( float f)
They basically do the same thing, square a number, but use
different argument datatypes.
2) Test Each function with: Using int 4, double 4.9, float
9.4
What happened when you use the correct numerical data type as input
?
What happened when you use the incorrect numerical data types as
inputs ?
What is the lesson this teaches you about functions/methods ?
In: Computer Science
C++ question.
I want to write all output to the file "output.txt", but it will write just first character. Can you fix it?
#include
#include
#include
#include
#include
using namespace std;
using std::cin;
using std::cout;
using std::string;
// remove dashes convert letters to upper case
string normalize(const string &isbn) {
string ch;
for (char i : isbn) {
if (i == '-') {
continue; // if "-" then skip it
}
if (isalpha(i)) {
i = toupper(i); // Check uppercase
}
ch += i;
}
return ch;
}
// return the number of digits in to the string
size_t numDigits(string &str) {
size_t numDigits = 0;
for (char ch : str) {
if (isdigit(ch)) {
++numDigits;
}
}
return numDigits;
}
enum ValidationCode {
Ok, // validation passed
NumDigits, // wrong number of digits
ExtraChars,// extra characters in isbn
Done
};
enum ValidationCode validate(string &isbn) {
int Done = 4;
string normal = normalize(isbn);
size_t count = numDigits(normal);
if (normal.size() == Done)
exit(0);
if (count != 10) {
return NumDigits;
}
if (normal.size() == 10 || normal.size() == 11 && normal[10] == 'X') {
return Ok;
}
return ExtraChars;
}
int main() {
// open a file
ofstream file("output.txt");
//The following code is taken from (https://en.cppreference.com/w/cpp/io/basic_ios/fail)
// check if the file can open
if(!file) // operator! is used here
{
std::cout << "File opening failed\n";
return EXIT_FAILURE;
} //end of borrowed code
// read a file
//The following code is referenced from (https://stackoverflow.com/questions/7868936/read-file-line-by-line-using-ifstream-in-c)
std::ifstream ifs("test_data.txt");
// check if the file can read
if (ifs.fail())
{
std::cerr << "test_data.txt could not read" << std::endl;
return -1;
} //end of referenced code
std::string str;
while (ifs >> str){
switch (validate(str)) {
case Ok:
cout << str << " is a valid isbn\n";
file << str << " is a valid isbn\n";
break;
case NumDigits:
cout << str << " doesn't have 10 digits\n";
file << str << " doesn't have 10 digits\n";
break;
case ExtraChars:
cout << str << " has extra characters\n";
file << str << " has extra characters\n";
break;
default:
cout << "ERROR: validate(" << str << ") return an unknown status\n";
file << "ERROR: validate(" << str << ") return an unknown status\n";
break;
}
}
ifs.close();
file.close();
}
test_data.txt
1-214-02031-3
0-070-21604-5
2-14-241242-4
2-120-12311-x
0-534-95207-x
2-034-00312-2
1-013-10201-2
2-142-1223
3-001-0000a-4
done
In: Computer Science
STRICT DOWNVOTE IF NOT DONE FULLY, WILL REPORT ALSO IF COPY PASTED OR MODIFIED ANSWER Develop a class, using templates, to provide functionality for a set of recursive functions. The functions specified as recursive must be written recursively (not iterativly). The UML class specifications are provided below. A main will be provided. Additionally, a make file will need to be developed and submitted. ● Recursion Set Class The recursion set template class will implement the template functions. recursionSet -length: int -*mySet: myType -MAX_VALUE = 500000 static const: int -LIMIT = 1000 static const: int +recursionSet() +recursionSet(const recursionSet&) +~recursionSet() +getSetLength() const: int +generateElements(int): void + getElement(int) const: myType +setElement(int, myType): void +readValue(const string) const: int +printSet() const: void +operator == (const recusrionSet&): bool +tak(myType, myType, myType) const: myType +printSeptenary(myType) const: void +squareRoot(myType, myType) const: myType -recSqRoot(myType, myType, myType) const: myType +recursiveSum() const: myType -rSum(int) const: myType +checkParentheses(string) const: bool -recChkPar(string, int, int) const: bool +recursiveInsertionSort(): void -recInsSort(int, int): void -insertInOrder(myType, int, int): voidYou may add additional private functions if needed (but, not for the recursive functions). Note, points will be deducted for especially poor style or inefficient coding. Function Descriptions • The recursionSet() constructor should set the length to 0 and mySet pointer to NULL. • The recusrsionSet(const recursionBucket&) copy constructor should create a new, deep copy from the passed object. • The ~recursionSet() destructor should delete the myType array, set the pointer to NULL, and set the size to 0. • The setElement(int, myValue) function should set an element in the class array at the given index location (over-writing any previous value). The function must include bounds checking. If an illegal index is provided, a error message should be displayed. • The getElement(int) should get and return an element from the passed index. This must include bounds checking. If an illegal index is provided, a error message should be displayed and a 0 returned. • The getSetLength() functions should return the current class array length. • The printSet(int) function should print the formatted class array with the passed number of values per line. Use the following output statement: cout << setw(5) << mySet[i] << " • "; Refer to the sample executions for formatting example. The readValue(string) function should prompt with the passed string and read a number from the user. The function should ensure that the value is 3 1 and £ MAX_VALUE. The function should handle invalid input (via a try/catch block). If an error occurs (out of range or invalid input) an appropriate message should be displayed and the user re- prompted. Example error messages include: cout << "readSetLenth: Sorry, too many " << "errors." << endl; cout << "readSetLenth: Error, value " << cnt << " not between 1 and " << numMax << "." << endl; • Note, three errors is acceptable, but a fourth error should end the function and return 0. The generateList(int) function should dynamically create the array and use the following casting for rand() to fill the array with random values. mySet[i] = static_cast(rand()%LIMIT); • • • The printSeptenary(myType) function should print the passed numeric argument in Septenary (base-7) format. Note, function must be written recursively. The recursiveSum() function will perform a recursive summation of the values in class data set and return the final sum. The function will call the private rSum(int) function (which is recursive). The rSum(int) function accepts the length of the data set and performs a recursive summation. The recursive summation is performed as follows: rSum ( position )= • { array[ 0] array[ position ] + rSum ( position−1) if position = 0 if position > 0 The tak(myType) function should recursively compute the Tak 1 function. The Tak function is defined as follows: tak ( x , y , z) = { z tak ( tak ( x−1, y , z) , tak ( y−1, z , x) , tak ( z −1, x , y ) ) 1 For more information, refer to: http://en.wikipedia.org/wiki/Tak_(function) if y≥ x if y < x• • The squareRoot(myType, myType) function will perform a recursive estimation of the square root of the passed value (first parameter) to the passed tolerance (second parameter). The function will call the private sqRoot(myType,myType,myType) function (which is recursive). The private recSqRoot(myType,myType,myType) function recursively determines an estimated square root. Assuming initially that a = x, the square root estimate can be determined as follows: recSqRoot ( x , a , epsilon) = • • • • • { 2 if ∣ a − x ∣ ≤ epsilon a 2 (a + x) sqRoot x , , epsilon 2 a ( ) if ∣ a 2 − x ∣ > epsilon The recursiveInsertionSort() function should sort the data set array using a recursive insertion sort. The recursiveInsertionSort() function should verify the length is valid and, if so, call the recInsSort() function to perform the recursive sorting (with the first element at 0 and the last element at length-1). The recInsSort(int, int) function should implement the recursive insertion sort. The arguments are the index of the first element and the index of the last element. If the first index is less than that last index, the recursive insertion sort algorithm is follows: ▪ Recursively sort all but the last element (i.e., last-1) ▪ Insert the last element in sorted order from first through last positions To support the insertion of the last element, the insertInOrder() function should be used. The insertInOrder(myType, int, int) function should recursively insert the passed element into the correction position. The arguments are the element, the starting index and the ending index (in that order). The function has 3 operations: ▪ If the element is greater than or equal to the last element in the sorted list (i.e., from first to last). If so, insert the element at the end of the sorted (i.e, mySet[last+1] = element). ▪ If the first is less than the last, insert the last element (i.e., mySet[last]) at the end of the sorted (i.e., mySet[last+1] = mySet[last]) and continue the insertion by recursively calling the insertInOrder() function with the element, first, and last-1 values. ▪ Otherwise, insert the last element (i.e., mySet[last]) at the end of the sorted (i.e., mySet[last+1] = mySet[last]) and set the last value (i.e., mySet[last]) to the passed element. The checkParentheses(string) function should determine if the parentheses in a passed string are correctly balanced. The function should call the private recChkPar(string, int, int) function (which is recursive) The recChkPar(string, int, int) function should determine if the parentheses in a string are correctly balanced. The arguments are the string, an index (initially 0), and a parenthesis level count (initially 0). The index is used to track the current character in the string. The general approach should be as follows: ◦ Identify base case or cases. ◦ Check the current character (i.e., index) for the following use cases: ▪ if str[index] == '(' → what to do then ▪ if str[index] == ')' → what to do then ▪ if str[index] == any other character → what to do then Note, for each case, increment the index and call function recursively.
In: Computer Science
I've already worked on isEmpty, so please check that and solve the other parts to the question as well. Will rate as soon an I see that it is answered.
In this section, you will implement a generic Stack
class implemented using linked list. Assume the linked list node
class is already defined as below:
public class LLNode<T> {
public LLNode<T> link;
public T info;
public LLNode(T in) { info = in; link = null; }
}
Note that both class variables are public so any outside class can access them directly. Also assume that class StackUnderflowException has been defined that inherits Java’s Exception class. Your task is to implement four methods in the generic class LinkedListStack<T>.
public class LinkedListStack<T> {
private LLNode<T> head; // head of linked list, also stack top pointer
public LinkedListStack() { head = null; } // constructor
public boolean isEmpty() { // [1 pts]
// TODO: return true if stack is empty, false otherwise
// NO MORE THAN 1 LINE OF CODE!
if(head.link == null) return true;
}
public void push(T element) { // [2 pts]
// TODO: push an element to the stack
// NO MORE THAN 3 LINES of CODE!
}
public T peek() throws StackUnderflowException { // [2 pts]
// TODO: return the top element of the stack (but do
NOT
// remove it). NO MORE THAN 4 LINES of CODE!
}
public T pop() throws StackUnderflowException { // [3 pts]
// TODO: remove and return the top element of the stack
// It throws StackUnderflowException if stack is empty
// NO MORE THAN 6 LINES of CODE!
}
In: Computer Science