Questions
Question 1 Afariwa farm operates a large farm on which cow are raised. The farm manager...

Question 1
Afariwa farm operates a large farm on which cow are raised. The farm
manager Kofi Manu determined that for the cow to grow in the desired
fashion, they need at least minimum amounts of four nutrients. Kofi
Manu is considering three different grains to feed the cow. The table
below lists the number of units of each nutrient in each kilogram of
grain, the minimum daily requirements of each nutrient for each cow,
and the cost of each grain. The manager believes that as long as a cow
receives the minimum daily amount of each nutrient, it will be healthy
and produce a standard amount of meat. The manager wants to raise
the cow at minimum cost.
Grain 1 Grain 2 Grain 3 Minimum
daily
requirement
(units)
Nutrient A 20 30 70 110
Nutrient B 10 10 0 18
Nutrient C 50 30 0 90
Nutrient D 6 2.5 10 14
Cost (GH¢) 41 36 96
a) Formulate a linear programming model for this problem.
b) Use solver to find optimal solution and sensitivity report.
c) Management have asked you to determine the optimal solution.
Write your answer in a form of a report to be submitted to the
management.
(d) Advice the management about objective function value
corresponding to your answer in (b).

In: Computer Science

Research the System Stability Index (SSI). Write a brief summary of its purpose and why it...

Research the System Stability Index (SSI). Write a brief summary of its purpose and why it might be a useful tool for a server admin.

Research the netstat command-line tool. Write a brief summary of its usage, options, and why it might be a useful tool for a server admin

In: Computer Science

In C++, Mrs. Jones wishes to computerize her grading system. She gives 5 tests but only...

  1. In C++, Mrs. Jones wishes to computerize her grading system. She gives 5 tests but only counts the 4 highest scores. Input the 5 test scores and output the average of the highest four. And using the following grading scale, 90-100 A, 80-89 B, 70-79 C, 60-69 D, and below 60 F, output the student’s letter grade. After creating this code, Modify the above to calculate the grade for all students in the class. The first input value will be the number of students in the class. You will then need to use a loop to input the students’ names as well as their 5 grades. Inside the loop (after calculating the average for the student) you will need to add each student’s average to a sum variable because at the end, you will need to print out the class average as well as each students’ names and letter grades.

In: Computer Science

Given a stack S and an element x, write a recursive algorithm that returns True if...

Given a stack S and an element x, write a recursive algorithm that returns True if x is in S, or False otherwise. Note that your algorithm should not change the content in S. What is the time complexity of your algorithm?

In: Computer Science

Write a loop that sets newScores to oldScores shifted once left, with element 0 copied to...

Write a loop that sets newScores to oldScores shifted once left, with element 0 copied to the end. Ex: If oldScores = {10, 20, 30, 40}, then newScores = {20, 30, 40, 10}.

--------------Code Below-----------

#include <iostream>
using namespace std;

int main() {
const int SCORES_SIZE = 4;
int oldScores[SCORES_SIZE];
int newScores[SCORES_SIZE];
int i;

for (i = 0; i < SCORES_SIZE; ++i) {
cin >> oldScores[i];
}

/* Your solution goes here */

for (i = 0; i < SCORES_SIZE; ++i) {
cout << newScores[i] << " ";
}
cout << endl;

return 0;
}

In: Computer Science

Given a positive integer n, write a recursive algorithm that returns the number of the digits...

Given a positive integer n, write a recursive algorithm that returns the number of the digits in n. For example, if the given number n is 12345, the algorithm should return 5. What is the time complexity of your algorithm?

In: Computer Science

Fill in the code only using pointer variables #include using namespace std; int main() { int...

Fill in the code only using pointer variables

#include

using namespace

std; int main() {

int longside; // holds longside (length)

int wideside; // holds wideside(width)

int total; // holds total (area)

int *longsidePointer = nullpointer; // int pointer which will be set to point to length

int *widthPointer = nullpointer; // int pointer which will be set to point to width

cout << "Please input the longside of the rectangle" << endl;

cin >> longside;

cout << "Please input the wideside of the rectangle" << endl;

cin >> wideside;

// Fill in code to make longsidePointer point to longside(length) (hold its address)

// Fill in code to make widesidePointer point to wideside(width) (hold its address)

total = // Fill in code to find the total(area) by using only the pointer variables

cout << "The total is " << total << endl;

if (// Fill in the condition longside(length) > wideside(width) by using only the pointer variables)

cout << "The longside is greater than the wideside" << endl;

else if (// Fill in the condition of wideside(width) > longside(length) by using only the pointer variables)

cout << "The wideside is greater than the longside" << endl;

else

cout << "The wideside and longside are the same" << endl;

return 0;

}

}

In: Computer Science

The user will input a dollar amount as a floating point number; read it from input...

The user will input a dollar amount as a floating point number; read it from input using a Scanner and the .nextDouble() method. Convert the number of dollars into a number of whole (integer) cents, e.g., $1.29 = 129 cents. Determine and output the optimal number of quarters, dimes, nickels, and pennies used to make that number of cents.

Ex: if the input is

1.18

The output should be

4
1
1
3

for 4 quarters, 1 dime, 1 nickel, 3 pennies.

Hints

  1. Remember that a double multiplied by an int gives back a double. You will need to cast the result to int if you want to do integer arithmetic, like modulo.
  2. % is modulo.
  3. There is no "f-string" equivalent in Java.

(STARTING CODE)

import java.util.Scanner;

public class Change {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);

/* Type your code here. */
}
}

In: Computer Science

Given a stack S and an element x, write a recursive algorithm that returns True if...

Given a stack S and an element x, write a recursive algorithm that returns True if x is in S, or False otherwise. Note that your algorithm should not change the content in S. What is the time complexity of your algorithm?

In: Computer Science

I ALREADY HAVE THE CORRECT ANSWERS. CAN YOU EXPLAIN TO ME HOW AND/OR WHY THESE ARE...

I ALREADY HAVE THE CORRECT ANSWERS. CAN YOU EXPLAIN TO ME HOW AND/OR WHY THESE ARE THE ANSWERS? THANK YOU :)

int a(int &x, int y) { x = y; y = x + 1; return y;

}

int b(int &x, int y) { y = x + 1; x = y; return y;

}

void c(int x, int y) { if (x > 2) return; cout << y; c(x + 1, y - 1);

}

int main() {

int x[2][3] = {{1, 2, 3}, {4, 5, 6}};

int y[3] = {7, 8, 9};

cout << x[1][1] << endl;   // line (a)

y[0] = a(y[0], y[1]);

cout << y[0] << y[1] << endl; // line (b)

cout << b(x[0][2], x[1][2]) << endl;    // line (c)

cout << x[0][2] << x[1][2] << endl; // line (d)

c(0, 4); cout << endl; // line (e)

}

(a) What is the output from the instruction beginning on line (a)?

Answer: 5

(b) What is the output from the instruction beginning on line (b)?

Answer: 98

(c) What is the output from the instruction beginning on line (c)?

Answer: 4

(d) What is the output from the instruction beginning on line (d)?

Answer: 46

(e) What is the output from the instruction beginning on line (e)?

Answer: 432

In: Computer Science

Refactor Assignment 1 into 3 project related files. Customer.h - Class Specification Customer.cpp - Class Implementation...

Refactor Assignment 1 into 3 project related files.

Customer.h            - Class Specification
Customer.cpp         - Class Implementation (Methods)

TestCustomer.cpp - Your code that performs the logic from Assignment 1.

The 3 files need to be named as listed above and should compile without errors.

I am not understanding how to do this.

Below is the code:

#include
#include

using namespace std;

const int NAME_SIZE = 20;
const int STREET_SIZE = 30;
const int CITY_SIZE = 20;
const int STATE_CODE_SIZE = 3;

class Customer
{
private:
   long customerNumber;

   char name[NAME_SIZE];
   char streetAddress_1[STREET_SIZE];
   char streetAddress_2[STREET_SIZE];
   char city[CITY_SIZE];
   char state[STATE_CODE_SIZE];

   int zipCode;

public:
   void setNumber(long number);

   bool setName(char name[]);
   bool setStreetAddress1(char street1[]);
   bool setStreetAddress2(char street2[]);
   bool setCity(char c[]);
   bool setState(char st[]);
   bool setZipCode(int zip);

   long getNumber();

   char* getName();
   char* getStreetAddress1();
   char* getStreetAddress2();
   char* getCity();
   char* getState();

   int getZipCode();
};


void Customer::setNumber(long number)
{
   customerNumber = number;
}

bool Customer::setName(char n[])
{
  
   if (strlen(n) > 0)
   {
       strcpy(name, n);
       return true;
   }

   return false;
}

bool Customer::setStreetAddress1(char street1[])
{

   if (strlen(street1) > 0)
   {
       strcpy(streetAddress_1, street1);
       return true;
   }

   return false;
}

bool Customer::setStreetAddress2(char street2[])
{
   if (strlen(street2) > 0)
   {
       strcpy(streetAddress_2, street2);
       return true;
   }

   return false;
}


bool Customer::setState(char st[])
{
  
   if (strlen(st) > 0)
   {
       strcpy(state, st);
      
       for (int i = 0; i < strlen(state); i++)
       {
           state[i] = toupper(state[i]);
           if (state[i] < 'A' || state[i] > 'Z')
               return false;
       }

       return true;
   }

   return false;
}

bool Customer::setCity(char c[])
{

   if (strlen(c) > 0)
   {
       strcpy(city, c);

       for (int i = 0; i < strlen(city); i++)
       {          
           city[i] = toupper(city[i]);
           if (city[i] < 'A' || city[i] > 'Z')
               return false;
       }

       return true;
   }

   return false;

}

bool Customer::setZipCode(int zip)
{

   if (zip >= 0 && zip <= 99999)
   {
       zipCode = zip;
       return true;
   }

   return false;
}


long Customer::getNumber()
{
   return customerNumber;
}

char* Customer::getName()
{
   return name;
}

char* Customer::getStreetAddress1()
{
   return streetAddress_1;
}

char* Customer::getStreetAddress2()
{
   return streetAddress_2;
}

char* Customer::getState()
{
   return state;
}

char* Customer::getCity()
{
   return city;
}

int Customer::getZipCode()
{
   return zipCode;
}

int main()
{
   Customer info;
  

   char name[NAME_SIZE];
   char streetAddress_1[STREET_SIZE];
   char streetAddress_2[STREET_SIZE];
   char city[CITY_SIZE];
   char state[STATE_CODE_SIZE];
   int zipCode;

   info.setNumber(1);

   do
   {
       cout << "What is your name: ";
       cin.getline(name, NAME_SIZE);
   } while (!info.setName(name));


   do
   {
       cout << "Street you live on: ";
       cin.getline(streetAddress_1, STREET_SIZE);
   } while (!info.setStreetAddress1(streetAddress_1));


   do
   {
       cout << "Second street(if applicable, type N/A if not): ";
       cin.getline(streetAddress_2, STREET_SIZE);
   } while (!info.setStreetAddress2(streetAddress_2));

   do
   {
       cout << "What state do you live in: ";
       cin.getline(state, STATE_CODE_SIZE);
   } while (!info.setState(state));

   do
   {
       cout << "What City do you live in: ";
       cin.getline(city, CITY_SIZE);
   } while (!info.setCity(city));

   do
   {
       cout << "what is the zip code: ";
       cin >> zipCode;
   } while (!info.setZipCode(zipCode));


  
   cout << "\n" << "Details of Customer: " << "\n";
   cout << "Customer Number: " << info.getNumber() << "\n";
   cout << "Name: " << info.getName() << "\n";
   cout << "Street Address 1: " << info.getStreetAddress1() << "\n";
   cout << "Street Address 2: " << info.getStreetAddress2() << "\n";
   cout << "State: " << info.getState() << "\n";
   cout << "City: " << info.getCity() << "\n";
   cout << "Zip code: " << info.getZipCode() << "\n";

   return 0;
}

In: Computer Science

How an isolated workspace is provided by docker to keep applications on the same host or...

How an isolated workspace is provided by docker to keep applications on the same host or cluster isolated from one another? Give a proper answer.

In: Computer Science

Question 1 (20pts): Create a dictionary of the form {“Jordan”: “Basketball”, “Federer”: “Tennis”, “Ronaldo”: “Football”} and...

Question 1 (20pts):

Create a dictionary of the form {“Jordan”: “Basketball”, “Federer”: “Tennis”, “Ronaldo”: “Football”} and perform the following actions

  • Print all the keys in the dictionary
  • Print all the values in the dictionary
  • Iterate through the dictionary and print the value only if the key is “Federer”
  • Iterate through the dictionary and print the key only if the value is “Football”

Question 2 (15pts):

List1 = [3, 4, 5, 20, 5]

List2 = [4, 9, 6, 2, 10].

Using list comprehensions, print the output if you multiply the i-th element of each list

Question 3 (15pts):¶

Dic1 = {"John":10, "Joe":15}

  • Check whether “John” is one of the keys
  • Remove the key “Joe” along with its associated value
  • Add another key and value pair - “Jean”: 40

Question 4 (15pts):

  • Write a user defined function to find the highest of the three numbers: 30, 10 and 20. The highest number should be printed. Note: The function has to be user defined.

  • With a given integral number n, write a program to generate a dictionary that contains key value pairs such as i: 2^i, and i takes values between 1 and n (both included). Then print the dictionary.

Suppose the following input is supplied to the program:

4

Then, the output should be:

{1: 2, 2: 4, 3: 8, 4: 16}

Question 5 (20pts):

  • Using list comprehensions, print all the values between 1 and 10 that are divisible by 2. The output should be [2, 4, 6, 8].

  • By using list comprehension, please write a program to print the list after removing the value 24 in [12,24,35,24,88,120,155].

Question 6 (15pts):

Remove the last value in [12,24,35,24,88,120,155] consecutively and print the removed value in each removal.

In: Computer Science

using java Design a class named Triangle that extends GeometricObject. The class contains: • Three double...

using java Design a class named Triangle that extends GeometricObject. The class contains: • Three double data fields named side1, side2, and side3 to denote three sides of a triangle. • A no-arg constructor that creates a default triangle with default values 1.0. • A constructor that creates a triangle with the specified side1, side2, and side3. In a triangle, the sum of any two sides is greater than the other side. The Triangle class must adhere to this rule and throw an IllegalTriangleException object if a triangle is created with sides that violate the rule • The accessor methods for all three data fields. • A method named getArea() that returns the area of this triangle. • A method named getPerimeter() that returns the perimeter of this triangle. • A method named toString() that returns a string description for the triangle. Write a test program that prompts the user to enter three sides of the triangle, a color, and a Boolean value to indicate whether the triangle is filled. The program should create a Triangle object with these sides and set the color and filled properties using the input. The program should display the area, perimeter, color, and true or false to indicate whether it is filled or not.

In: Computer Science

Rectangle Class in C++ Create a Rectangle class that has two data members: length_ and width_....

Rectangle Class in C++

Create a Rectangle class that has two data members: length_ and width_. Create the corresponding accessor and mutator functions to access and change both data members.

Create a member function area that returns the area of the Rectangle object. Finally, create a function longest_rectangle that accepts two Rectangle objects as parameters and returns the Rectangle object with the longer length.

Write the Rectangle class and the longest_rectangle function prototype in rectangle.hpp. Take note that longest_rectangle is not a member function of the Rectangle class. Provide the function's implementation in rectangle.cpp.

Complete main.cpp according to the comments provided in the file.

Sample Output:

Rectangle 1
Please enter the length: 2
Please enter the width: 3
Rectangle 1 created with length 2 and width 3
The area of Rectangle 1 is: 6

Rectangle 2
Please enter the length: 4
Please enter the width: 5
Rectangle 2 created with length 4 and width 5
The area of Rectangle 2 is: 20

The longest rectangle has a length of 4, a width of 5, and an area of 20.

Submission checklist

  1. Created function prototype and stored in .hpp file.
  2. Created function implementation and stored in .cpp file (see reference).
  3. Call function in the driver
  4. Compiled and ran the driver (main).
  5. Manually checked for compilation and logical errors.
  6. Ensured no errors on the unit test (make test).
  7. Followed advice from the stylechecker (make stylecheck).
  8. Followed advice from the formatchecker to improve code readbility (make formatcheck).

In: Computer Science