Write a C++ function that receives an integer array along with its specified length. The function will replace only one of the smallest integers and one of the largest integers by 0. Then the function will return the average for the rest of the values in the array.
Test case array: 3, 8, 2, 6, 5, 3, 4, 7, 8, 2, 10, 7
Function should return: 5.3
In: Computer Science
Report for Movie: Prometheus
What AI techniques/methods/devices/applications were mentioned in the movie and How accurate are the AI predictions on the movie set in our present time? Or, how realistic are those predictions if the time is yet to come?(400 words or above)
In: Computer Science
/*
* C++ Program to Implement Hash Tables with Quadratic Probing
*/
#include <iostream>
#include <cstdlib>
#define MIN_TABLE_SIZE 10
using namespace std;
//-----------------------------------------------------------------------
// Node Type Declaration
//-----------------------------------------------------------------------
enum EntryType
{
Legi, Emp, Del
};
//-----------------------------------------------------------------------
// Node Declaration
//-----------------------------------------------------------------------
struct HashTableEntry
{
int e;
enum EntryType info;
};
//-----------------------------------------------------------------------
// Table Declaration
//-----------------------------------------------------------------------
struct HashTable
{
int size;
HashTableEntry *t;
};
//-----------------------------------------------------------------------
// Function: isPrime Function
// Return whether n is prime or not
//-----------------------------------------------------------------------
bool isPrime (int n) //Complete the function stubs needed to
implement the operations
{
if( n == 2 || n == 3 )
return true;
if( n == 1 || n % 2 == 0 )
return false;
for( int i = 3; i * i <= n; i += 2 )
if( n % i == 0 )
return false;
return true;
}
//-----------------------------------------------------------------------
// Function: nextPrime Function
// Finding next prime size of the table
//-----------------------------------------------------------------------
int nextPrime(int n)
{
if (n % 2 == 0)
++n;
while (!IsPrime(n)) n += 2;
return n;
}
//-----------------------------------------------------------------------
// Function: Hash Function
//-----------------------------------------------------------------------
int HashFunc(int key, int size) //Complete the function stubs
needed to implement the operations
{
}
//-----------------------------------------------------------------------
// Function: initiateTable Function
// Initialize Table
//-----------------------------------------------------------------------
HashTable *initiateTable(int size)
{
HashTable *ht;
if (size < MIN_TABLE_SIZE)
{
cout<<"Table Size is Too Small"<<endl;
return NULL;
}
ht= new HashTable;
if (ht == NULL)
{
cout<<"Out of Space"<<endl;
return NULL;
}
ht->size = nextPrime(size);
ht->t = new HashTableEntry [ht->size];
if (ht->t == NULL)
{
cout<<"Table Size is Too Small"<<endl;
return NULL;
}
for (int i = 0; i < ht->size; i++)
{
ht->t[i].info = Emp;
ht->t[i].e = 0;
}
return ht;
}
//-----------------------------------------------------------------------
// Function: Search Element at a key
//-----------------------------------------------------------------------
int SearchKey(int key, HashTable *ht) //Complete the function stubs
needed to implement the operations
{
}
//-----------------------------------------------------------------------
// Function: Insert Element at a key
//-----------------------------------------------------------------------
void Insert(int key, HashTable *ht) //Complete the function stubs
needed to implement the operations
{
}
//-----------------------------------------------------------------------
// Function: Rehash
//-----------------------------------------------------------------------
HashTable *Rehash(HashTable *ht) //Complete the function stubs
needed to implement the operations
{
}
//-----------------------------------------------------------------------
// Function: Display Hash Table
//-----------------------------------------------------------------------
void display(HashTable *ht)
{
for (int i = 0; i < ht->size; i++)
{
int value = ht->t[i].e;
if (!value)
cout<<"Position: "<<i + 1<<" Element:
Null"<<endl;
else
cout<<"Position: "<<i + 1<<" Element:
"<<value<<endl;
}
}
In: Computer Science
C++ Design and implement a program (name it ComputeAreas) that defines four methods as follows: Method squareArea (double side) returns the area of a square. Method rectangleArea (double width, double length) returns the area of a rectangle. Method circleArea (double radius) returns the area of a circle. Method triangleArea (double base, double height) returns the area of a triangle. In the main method, test all methods with different input value read from the user. Document your code and properly label the input prompts and the outputs as shown below. Sample run: Square side: 5.1 Square area: 26.01 Rectangle width: 4.0 Rectangle length: 5.5 Rectangle area: 22.0 Circle radius: 2.5 Circle area: 19.625 Triangle base: 6.4 Triangle height: 3.6 Triangle area: 11.52
In: Computer Science
In C++, write a program that creates a two-dimensional array initialized with some integers. Have the following six functions: Total (total of all values in array), Average (average of values in array), Total of specific row (this needs 2 arguments, the array, like the others, and an integer for the subscript of any row. Total of specific Column (same as row), Max value in Row ( same as previous two, but return the highest value), Minimum Value ( same as previous).
In: Computer Science
ou are a consultant for the business 'MSU eCommerce Consulting Services'. It is your role within the company to respond to customers that have lodged an eCommerce query that requires action. All clients that you are directed to respond to have an ongoing relationship with your company and have pre-paid blocks of time for any queries they have. ---- Clients need to know that the advice is accurate so you will need to provide references to back up your assertions. References used must be from reliable sources; Wikipedia or other crowdsourced services may contain accurate information, however this advice needs to be backed up with reputable sources that can withstand scrutiny. Be sure to read the marking criteria to see how you will be assessed. Overall it is important to have a mix of relevant theoretical concepts and real world examples presented in a manner that the client can understand. Task Requirements You are to write a professional business style email response to the following client. A response template is provided under 'Presentation' below. Client 1 Name: Mr Michael Fitzgerald Background: Business owner of music shop, 'True Test Safes'. Incoming correspondence: Hello, My company manufactures custom made cash safes within Australia using local and imported components however these components are becoming more and more costly to purchase from our local suppliers. I still wish to continue to manufacture safes in Australia but I would like procure the most costly parts from a cheaper source. I have heard of eMarketplaces but am unsure as to what types exist and how to progress. It is very important that the quality of these parts is consistently high. Please advise as to the options I have in purchasing from an eMarketplace, what marketplaces you recommend I use, and any risks specific to eMarketplaces that I need to be made aware. I look forward to your response. Thanks. Michael Fitzgerald Owner, True Test Safes Rationale The objective of this assessment is to develop your ability to: Analyse technology needs in specific situations and develop customer-focused plans and correspondence Evaluate problems posed by utilising electronic commerce.
In: Computer Science
(In C++ (very quick question))
1. Write a complete program. Declare a 2-Dimensional (size 20 x 30) integer array and use random numbers from 0 to 99 to initialize it. Define the prototype and the definition for a function called Find99(). The function takes three parameters: a 2-Dimensional array of integers (size 20 x 3), and 2 integers to specify the sizes of row and column of the array. (These two parameters should be used in your loops for checking the sizes of row and column.)
The function must check each element of the array. If the element contains the integer 99, the function should print the position of the number 99. (Hint: there may be multiple 99s or no 99 at all.)
Sample output: 99 is located at row 0 and column 0.
In: Computer Science
Can someone find what's wrong? If I don't use the last main method Netbeans says that there is no main method. I can't figure out what's wrong.
This was the prompt:
Design a class named triangle that extends geometricObject. For this, you should have created a GeometricObject class first. The class contains:
Your main method should create a triangle object and display it using toString()
This is my code:
package geometricobject;
/**
*
*
*/
public class GeometricObject {
/**
* @param args the command line arguments
*/
private String color = "white";
private boolean filled;
private java.util.Date dateCreated;
public GeometricObject() {
dateCreated = new java.util.Date();
}
public GeometricObject(String color, boolean filled) {
dateCreated = new java.util.Date();
this.color = color;
this.filled = filled;
}
public String getColor() {
return color;
}
public void setColor(String color) {
this.color = color;
}
public boolean isFilled() {
return filled;
}
public void setFilled(boolean filled) {
this.filled = filled;
}
public java.util.Date getDatecreated() {
return dateCreated;
}
public String toString() {
return "created on" + dateCreated + "\ncolor: " + color+ " and
filled: " + filled;
}
public class triangle extends GeometricObject
{
private double side1;
private double side2;
private double side3;
public triangle() {
side1 = 1;
side2 = 1;
side3 = 1;
}
public triangle(double side1, double side2, double side3) {
this.side1 = side1;
this.side2 = side2;
this.side3 = side3;
}
public double getSide1() {
return side1;
}
public double getSide2() {
return side2;
}
public double getSide3() {
return side3;
}
public void setSide1(double side1) {
this.side1 = side1;
}
public void setSide2(double side2) {
this.side2 = side2;
}
public void setSide3(double side3) {
this.side3 = side3;
}
public double getArea() {
double n = (side1+side2+side3) / 2.0;
return Math.sqrt(n*(n-side1)*(n-side2)*(n-side3));
}
public double getPerimeter() {
return side1 + side2 + side3;
}
@Override
public String toString() {
return super.toString() + "Triangle: side1 = " + side1 + " side2 =
" + side2 + "side3 = " + side3 ;
}}}
In: Computer Science
USING C++
Create a program that defines a struct for a student. The following data should be part of the struct: studentID (int), gpa(double), fullName(string), units(int).
Instantiate two students and have the user type in information for each, then print both back to the screen afterwards. Input validation: studentID should be positive and have 4 digits, GPA should be between 0 and 4 (inclusive), units should be positive. Have any invalid inputs reentered.
In: Computer Science
Tree Traversals It should be noted that, in class, all traversal
methods were written as recursive algorithm (i.e. at some point,
the method called itself). It is possible to implement
non-recursive versions of preorder, inorder, and postorder
traversal methods mentioned in class. One intuitive way is by using
a stack.
1) Give written pseudocode/explanation of :
a) How to build the tree such that a given non-recursive traversal
method can be used.
b) Your algorithm for a non-recursive preorder, inorder, OR
postorder traversal method (You only have to pick one)
2) Implement the above mentioned algorithms. Traversals should
print out nodes in their required order.
In: Computer Science
what is meant by the term data consolidation
In: Computer Science
a): Suppose we have developed the following rules and facts for
our system.
Rule 1: If X is an animal then X is living spices
Rule 2: If X is living spices then X is a life form
Rule 3: If X is a life form then X is mortal
Fact: Dog is an animal.
Goal: Is Dog a mortal?
Problem: Using forward chaining, try to conclude that Dog is mortal.
b)The following is the rule set of a simple weather forecast expert system:
Rule 1. IF cyclone THEN clouds
Rule 2. IF anticyclone THEN clear sky
Rule 3. IF pressure is low THEN cyclone
Rule 4. IF pressure is high THEN anticyclone
Rule 5. IF arrow is down THEN pressure is low
Rule 6. IF arrow is up THEN pressure is high
Problem: Use backward chaining to reason about the weather if
the working
memory contains the fact: clouds. Show your answer in a table
naming the
rules matching the current working memory (conflict set), which
rule you
apply, and how the working memory contents changes on the next step
after a
rule has fired:
hnt: artificial intelligence question
In: Computer Science
Design a class named Employee. The class should keep the following information in fields: • Employee name • Employee number in the format XXX–L, where each X is a digit within the range 0–9, and the L is a letter within the range A–M. • Hire date Write one or more constructors and the appropriate accessor and mutator methods for the class. Next, write a class named ProductionWorker that inherits from the Employee class. The ProductionWorker class should have fields to hold the following information: Shift (an integer) Hourly pay rate (a double) The workday is divided into two shifts: day and night. The shift field will be an integer value representing the shift that the employee works. The day shift is shift 1, and the night shift is shift 2. Write one or more constructors and the appropriate accessor and mutator methods for the class. Demonstrate the classes by writing a program that uses a ProductionWorker object. In a particular factory, a shift supervisor is a salaried employee who supervises a shift. In addition to a salary, the shift supervisor earns a yearly bonus when his or her shift meets production goals. Design a ShiftSupervisor class that inherits from the Employee class. The ShiftSupervisor class should have a field that holds the annual salary, and a field that holds the annual production bonus that a shift supervisor has earned. Write one or more constructors and the appropriate accessor and mutator methods for the class. In a particular factory, a team leader is an hourly paid production worker who leads a small team. In addition to hourly pay, team leaders earn a fixed monthly bonus. Team leaders are required to attend a minimum number of hours of training per year. Design a TeamLeader class that inherits from the ProductionWorker class. The TeamLeader class should have fields for the monthly bonus amount, the required number of training hours, and the number of training hours that the team leader has attended. Write one or more constructors and the appropriate accessor and mutator methods for the class. Demonstrate the classes by writing a program that uses a TeamLeader object and a ShiftSupervisor object, as well as an Employee object. Be sure that all methods defined are called.
In: Computer Science
In: Computer Science
Discuss a specific situation where association rules are used, or could be used, in your organization or in one with which you are familiar. Which association rules are relevant to the organization and why?
In: Computer Science