//Please fill in the functions at the bottom of the file. (evenCount and insertItem)
//DO NOT CHANGE ANYTHING ELSE.
//main has all the code needed to test your functions. Once your functions are written, please build and make sure it works fine
#include <iostream>
#include <fstream>
using namespace std;
//constants
const int CAP = 100;
//function prototypes
bool openFile(ifstream &);
void readData(ifstream &, int [], int &);
void printData(const int [], int);
void evenCount(const int[], int);
void insertItem(int[], int &, int, int);
int main()
{
ifstream inFile;
int list[CAP], size = 0;
if (!openFile(inFile))
{
cout << "Program terminating!! File not found!" << endl;
return -1;
}
//read the data from the file
readData(inFile, list, size);
inFile.close();
cout << "Data in file:" << endl;
printData(list, size);
//insert a few items
insertItem(list, size, 15, 5);
cout << "Inserted in position 5:" << endl;
printData(list, size);
insertItem(list, size, 101, 2);
cout << "Inserted in position 5:" << endl;
printData(list, size);
insertItem(list, size, 215, 12);
cout << "Inserted in position 5:" << endl;
printData(list, size);
//call the evenCount function
evenCount(list, size);
//end program
cin.ignore(100, '\n');
cout << "Press any key to continue...";
getchar();
return 0;
}
//function to open file
bool openFile(ifstream &inFile)
{
inFile.open("numbers.txt");
if (!inFile)
{
return false;
}
return true;
}
//reads the data from the file
void readData(ifstream &inFile, int list[], int &size)
{
while (!inFile.eof())
{
inFile >> list[size++];
}
}
//print the contents of the array
void printData(const int list[], int size)
{
for (int i = 0; i < size; i++)
{
cout << list[i] << endl;
}
cout << endl;
}
//insert an item (newNum) in the given position (newPos)
void insertItem(int list[], int &size, int newNum, int newPos)
{
//insert code here
}
//count the even numbers in the list and output in this function
void evenCount(const int list[], int size)
{
//insert code here
}In: Computer Science
1. Famed B-Law Survivor and professional soccer player extraordinaire Mr. Josh “Galway United” fondly known to his friends as “Blue-eyed Devil,” transfers real property he owns and the deed reads, “I transfer this property to the U.C. Santa Clara Rodent Soccer Team so long as it is used to promote soccer playing rodents, and if it ceases to be so used, then it comes back to me.” Assuming that California law controls, the type of ownership estate created is:
A) Fee simple absolute.
B) Fee simple subject to remainder.
C) Fee simple defeasible with reversion.
D) Life estate.
E) Community property.
2. Assume that the deed reads, “I transfer this property to the U.C. Santa Clara Rodent Soccer Team so long as it is used to promote soccer playing rodents, and if it ceases to be so used, then it goes to my rarely sober soccer playing friends and B-Law Survivors all, [Geremy Uhlster, David Martini, Adam Beerman, Brandon “Cockapoo” McDonald, Bryan NoCura, Katie “40 oz” Fosters, Kyle Clump, Jeffrey Hustle, Jessie Hinder-son, O.D. O’Donnell, JD Warrant, Felipe “Porsche” Carrera, Jeff “Bad Intentions” Pensta, Heist Niehe, Knick Smith, Andy Swooped, Vigard “Viking” Karlsen, Fred “Lurch” Loechen, Brendan “Area 51” Roswall, Christina Moped, Samir “Soccer-Sam”, Najmeh, Celia “Cool Drink” Pellegrino, Kyle McLoud, Miguel “All Academic” Aguilar, Sixto “Pour Me-A-Cold-One” Porras, “I’m Not Mitt” Dave Romney, , Aaron “Vince” Lombardi, Jonathan “Fabulous” Fabulich, Kam “Raven” Krow, and honorary Survivor Fiona "Temperance" O’Sullivan. (Names changed to protect the innocent)]. What have Mr. Smith’s rarely sober friends acquired?
A) Fee simple absolute.
B) Fee simple defeasible.
C) Life estate.
D) Remainder interests.
E) Community Property.
3. The Dean of the School of Business hires the world’s most famous International dance company “The Paisanos” (Lupo Benatti, Felix Jermanan, Maria-Claudia Tortella, Giorgia Scelzo, Sergio Mandrone, Alberto Zini and Martina Granieri) to teach the Business Law faculty the latest hip-hop dances. “The Paisanos” quoted the Dean a price of $6,000 per faculty member for the dance instruction. After 20 minutes of lessons, the troupe discovered that the faculty has absolutely no rhythm and incredibly, they each have two left feet! To teach this “rhythmatically challenged” group would take substantially more time and cost more money. “The Paisanos” say they will continue, but only if the Dean pays them $2,000 for each extra left foot. If the Dean’s promise to pay an increased amount is enforceable it is because:
A) This is a valid settlement of a liquidated debt.
B) This is an unforeseen circumstance.
C) This is a Uniform Commercial Code modification.
D) This is a preexisting duty.
E) This is a novation.
In: Accounting
1) You plan a meal with the following ingredients and requirements:
| bread | potatoes | meat | beans | eggs | butter | requirement | ||
| units | lb | lb | oz | lb | number | oz | ||
| cost | $1.89 | $0.75 | $0.48 | $2.29 | $0.15 | $2.85 | ||
| calaries | 280 | 250 | 43 | 78 | 160 | 300 | 2200 | at least |
| vitamin A | 5 | 15 | 37 | 20 | 12 | 0 | 300 | at least |
| vitamin c | 0 | 70 | 0 | 50 | 0 | 0 | 60 | at least |
| protein | 3 | 5 | 40 | 12 | 10 | 0 | 80 | at least |
| fat | 8 | 2 | 25 | 3 | 18 | 30 | 50 | at least |
a. Find the cheapest meal that satisfies all the requirements. What are the ingredients and what is the total cost.
b. Find the integer solution to this problem.
c. Can you use these results?
2) You have three plants that produce a certain type of boats. The capacity for next month is 38 in San Diego, 45 in Santa
Ana, and 58 in San Jose. Production cost per boat is $1,065 in San Diego, $1,005 in Santa Ana, and $975 in San Jose.
Demand for next month is 42 in Newport Beach, 33 in Long Beach, 14 in Ventura, 10 in San Luis Obispo, and 22 in San
Francisco. The shipping costs per boat are summarized in the following table:
| Shipping | Cost | to: | |||
| From | NB | LB | VEN | SLO | SF |
| SD | $200 | $220 | $280 | $350 | $400 |
| SA | $125 | $125 | $280 | $350 | $400 |
| SJ | $390 | $365 | $300 | $250 | $100 |
Develop a production and shipping schedule that minimizes the total cost of production and shipping while satisfying all
the demand.
3) You own a wheat warehouse with a capacity of 20 thousand bushels. At the beginning of month 1, you have 6 thousand
bushels of wheat. Each month, wheat can be bought and sold at the prices per one thousand bushels shown in the table
below.
The sequence of events during each month is as follows:
You observe your initial stock of wheat.
You can sell any amount of wheat up to your initial stock at the current month’s selling price.
You can buy as much wheat as you want, subject to the warehouse size limitation.
Determine how to maximize the profit earned over the next 10 months by finding the quantities to sell and buy each
month. What is your profit?
| selling price | purchase price | |
| month 1 | $3 | $8 |
| month 2 | $6 | $8 |
| month 3 | $7 | $2 |
| month 4 | $1 | $3 |
| month 5 | $4 | $4 |
| month 6 | $5 | $3 |
| month 7 | $5 | $3 |
| month 8 | $1 | $2 |
| month 9 | $3 | $5 |
| month 10 | $2 | $5 |
In: Operations Management
In your latest home assignment, you were asked to write a generic method that returns an ArrayList that contains the non-duplicate elements from the original list. For this question, write a generic method that returns an ArrayList that contains the non-duplicate elements or the duplicate elements depending on the boolean argument (dup) setting.
If dup = false, return the list with the non-duplicates,
else return the list with the duplicated elements in the original list.
Please use the following two arrays for this question.
Integer[] nlist = { 0, 24, 25, 14, 25, 24, 42, 45, 42, 25};
String[] srt = {"Sam", "Bob", "Sue","Bob","Matt","Nick","Sue","Bob"};
Use the following static method (Array2Collection(….) to convert them to two corresponding ArrayLists ( 4 points)
public static <T> void Array2Collection(T a[], Collection<T> c) {
for (T x: a)
c.add(x);
}
Write codes to return an ArrayList <E>: if dup = false, return the list with the non-duplicates, else return with the duplicated element in the original list.
// 24 points for codes inside this method.
public static <E> ArrayList<E> Duplicates(ArrayList<E> list, boolean dup) {
// add codes here….
// 4 points for preparing the arrayList(s) from the two given arrays.
// 15 points for building the two arrayList of elements from the original list
// 5 points for returning the appropriate list based on the dup switch
}
Your client prgram should display this:
original list[0, 24, 25, 14, 25, 24, 14, 42, 45, 42, 25]
nodup list [0, 24, 25, 14, 42, 45]
dup list [25, 24, 14, 42, 25]
-------------
original list[Sam, Bob, Sue, Bob, Matt, Nick, Sue, Bob]
nodup list[Sam, Bob, Sue, Matt, Nick]
dup list[Bob, Sue, Bob]
In: Computer Science
In C++
Write the definition for following methods of List data structure.
1. setList – The function set the value of list elements equal to a value passed as the function input.
2. getAt – The function returns an element of the list referred by its position which is given to the function as input.
3. insertAt – The function inserts a given element passed as function input in the list at the specified position also passed as second function input. The insertion should happen only on the existing elements of the array. The operation increases the number of elements in the list by one.
4. removeAt – The function remove an element from the list at the specified position. The removal should happen only on the existing elements of the array. The operation decreases the number of elements in the list by one
In: Computer Science
Problem (multiple regression). Following data are taken from textbook (p.614)
|
Student |
Math-proficiency X1 |
SAT-Math X2 |
Calculus final (college 1st year) Y |
|
1 |
72 |
462 |
71 |
|
2 |
96 |
545 |
92 |
|
3 |
68 |
585 |
72 |
|
4 |
86 |
580 |
82 |
|
5 |
70 |
592 |
74 |
|
6 |
73 |
516 |
71 |
|
7 |
91 |
638 |
100 |
|
8 |
75 |
615 |
87 |
|
9 |
76 |
596 |
81 |
V= 56331/9 = 6259 S=sqrt6259 = 79.1
The least-square equation is Y=-26.6+0.777X1+0.082 X2, that is :
Calculus final=-26.6+0.777 *math-proficiency +0.082* Sat-Math
In: Statistics and Probability
v. Find the margin of error given the following: 99% confidence interval;
n = 68, x bar = 4156 and Std dev. = 839. ________
a. 1298 b. 237 c. 262 d. 8
vi. When do Type II errors occur?________
a. We decide to reject the null hypothesis when the null hypothesis was actually true.
b. We fail to reject the null hypothesis when the null hypothesis is actually false.
c. They occur in both cases.
vii. A standard score of z = 1.00 for an observation means: _________
a. The mean of the distribution lies 1 standard deviations below the observation.
b. The observation lies 1 standard deviations below the mean.
c. The observation lies 1 standard deviations above the mean.
d. The observation lies 1 means below the standard deviation.
viii. Given a 90% and a 95% confidence interval, which of the following is true?
ix. The number of hours per week that high school juniors watch TV is normally distributed with a mean of 8 hours and a standard deviation of 2 hours. If 100 students are chosen at random, find the probability that the mean for that sample is between 8.2 and 8.8
Note: standard deviation/ the square root of n.
Check out the Central Limit Theorem
In: Math
Create a class DogWalker
member List <String>doggies
method: void addDog(String name ) //add dog to the List
method: void printDogList() //print all dogs in list
/* You’ll need an index. Iterate over your list of dog names in a while loop. Use your index to “get” the dog at the current index When you ‘find’ your dog name in the list, print it out */
Method: void findDogUsingWhile(String dogName)
/* You’ll need an index. Iterate over your list of dog names in a while loop. Use your index to “get” the dog at the current index When you ‘find’ your dog name in the list use the index to remove it from the list */
Method: String removeDogUsingWhile(String dogName)
/* Iterate over your list of in dog names using an iterator. When your iterator points to the dogname in your list ‘equals’ the dogName passed in Print ‘I found my dog: ’ + dog name */
Method void findDogUsingIterator(String dogName)
/* Iterate over your list of dog names using an iterator. When your iterator points to the dogname in your list ‘equals’ the dogName passed in Use your iterator to remove the element */
Method void removeDogUsingIterator(String dogName)
In your testHarness:
- create a DogWalker instance
- add a batch of (Dog) Names to the List in your DogWalker class ( using your addDog method)
- invoke findDogUsingWhile(String dogname)
- invoke removeDogUsingWhile(String dogname)
- invoke printDogList()
- invoke findDogUsingIterator(String dogname)
- invoke removeDogUsingIterator(String dogname)
- invoke printDogList()
In: Computer Science
If 1 mL of a 0.02% w/v isoproterenol hydrochloride solution is diluted to 10 mL with sodium chloride injection before intravenous administration, calculate the percent concentration of the diluted solution.
In: Nursing
Using mathematical notation where appropriate, briefly define the following properties of preferences: (i) completeness, (ii) transitivity, (iii) monotonicity, (iv) convexity, (v) continuity and (vi) rationality
In: Economics