C++Design and implement a program (name it LinearBinarySearch) to implement and test the linear and binary search algorithm discussed in the lecture slides. Define method LinearSearch() to implement linear search of an array of integers. Modify the algorithm implementation to count number of comparisons it takes to find a target value (if exist) in the array. Define method BinarySearch() to implement binary search of an array of integers. Modify the algorithm implementation to count number of comparisons it takes to find a target value (if exist) in the array. Now, develop a test method to read integer values from the user in to an array and then call methods LinearSearch() and BinarySearch() and printout the number of comparison took to find the target values using each search method. Document your code and organized your outputs as follows: Arrays Values: Target value: Linear Search Comparisons: Binary Search Comparisons:
In: Computer Science
Would it be useful to have an encryption that is additive and multiplicative in Homomorphic?
In: Computer Science
We will use El Paso information for our python script to compute property taxes for a home. We will default and use the Ysleta Independent School District tax rate for our school (more complete lookups will allow you to compute taxes based on exact address.) The taxing entities, and their respective tax rates per $100 is shown below:
Jurisdiction Total Rate ($) per $100
YSLETA ISD 1.3533
CITY OF EL PASO 0.907301
COUNTY OF EL PASO 0.488997
UNIVERSITY MEDICAL CENTER OF EL PASO 0.267747
EL PASO COMMUNITY COLLEGE 0.141167
Python Script Instructions: Create a loop that will allow the user to input a property value and calculate its related tax payment. Output property information as described below. The user will be asked to continue for another property or quit.
This will be a script broken into functions. It must include (may include more):
• Main function • Calculate property tax function
• Output information function called from Calculate function. Output will include the amount for each jurisdiction, and amount owed per year.
Other important information: We will assume each property value is eligible for a 10% Homestead Exemption of the property’s value. For example, if a property value is $100,000, the person would receive an exemption of $10,000. Their property taxes would be calculated on $90,000.
Don’t forget the rate is applied per $100 (i.e. you have to divide the amount for each jurisdiction you calculated by 100)
Sample calculation: Property value: $175,000 Yearly taxes owed: $4,974.66
In: Computer Science
Your friend wants to start an ecommerce website to commercialize some crafts she has been creating. She has approached you for an explanation on the basics to start an ecommerce website.
Write a 1 - 2 page essay explaining to your friend what she needs to know to begin an e-commerce website. As part of your essay make sure you include:
• A definition of what ecommerce is.
• A definition of the Internet and the World Wide Web, and how they are used to facilitate ecommerce.
• Categories of ecommerce, and the category that your friend would beimplementing.
• How the key components of an eBusiness solution work (front end/ back end).
• The steps your friend would follow to set up an ecommerce website:
o Selecting an eCommerce business strategy
o Getting a domain name
o Developing a site (tools, design, services)
o Deciding whether to develop/host the site herself or seek an external host service provider (identify the pros/cons of each decision)
o Implementing a methodto collect payments
o Establishing basic management methods to mitigate typical security threats (describe some typical threats)
In: Computer Science
9.12) How do you write a PHP script that collects the data from the form provided below and write it to a file?
.html
<!doctype html public "-//w3c//dtd html 4.0
transitional//en">
<html>
<head>
<title>Song Survey</title>
</head>
<body>
<form method="post" action="http://localhost/lab/lab
14.php"><br />
<h3>Enter The Date</h3>
<table>
<tr>
<td>Name Of The Song:</td>
<td><input type="text" name="SongName"
size="30"></td>
</tr>
<tr>
<td>Name Of The Composer:</td>
<td><input type="text" name="CName"></td>
</tr>
<tr>
<td>Name Of The Singer:</td>
<td><input type="text" name="Singer"></td>
</tr>
<tr>
<td><input type="submit"
value="Submit"></td>
</tr>
</table>
</form>
</body>
</html>
.php
<html>
<head>
<title>Song Information</title>
</head>
<body>
<?php
$SName=$_POST["SongName"];
$CName=$_POST["CName"];
$Singer=$_POST["Singer"];
$song_file= 'song.txt';
$file_handle = fopen($song_file, 'a') or die('Cannot open file:
'.$song_file);
fwrite($file_handle,$SName);
fwrite($file_handle,"#");
fwrite($file_handle,$Singer);
fwrite($file_handle,"##");
fwrite($file_handle,$CName);
fwrite($file_handle,"\r\n");
fclose($file_handle);
?>
<p>The Contents Are Written to the file
<u>song.txt</u></p>
<?php
$file_handle = fopen("song.txt", "rb");
print "<h4>The Most Popular songs are.....</h4>";
while (!feof($file_handle))
{
$line_of_text = fgets($file_handle);
$parts = explode(' # ',$line_of_text);
print ("$parts[0]<br/>");
}
fclose($file_handle);
?>
</body>
</html>
In: Computer Science
C++
If I want to ask the user to input the variables in a vector, how
can I do that?
I'm trying to implement this in a program with matrices. So the user should enter how many rows and columns they want, then enter the values
Can you help me out
In: Computer Science
in C++
Using your previous homework code:
1) Add a default constructor for the runners. ( one that has no parameters)
2) Add a constructor that takes a name and a bib number
3) Add a constructor that takes a name , a bib number and a sex.
Add setter functions that sets the time:
1) one that takes a string of the format : hh:mm:ss
2) one that takes an int that is the number of seconds the runner took to complete the race.
Please Note: You decide what format inside the class to store the time amount.
Add getter functions that return the time:
1) one that returns a string in the format : hh:mm:ss
2) one that returns an int that this the time in seconds.
Add a comment section to your class and explain why you chose some things.
1) What data type did you decide on in the class for the time, why
2) What was an alternative? Is your decision a big decision or a small decision? why
Please note : Again pick one C++ data type inside the class to store the time.
Do not use two variables to store the time.
Please note: if you write conversion functions that if expected. Do not make them public.
Please note: on the time returned as a string please test and verify that times like these contain the correct zeros not blanks. the format will always be either: ( b = blank, hh = hours, mm = minutes, ss = seconds )
bh:mm:ss
hh:mm:ss
so a time like 1:03:02 will NOT be displayed as : 1:3:2. I strongly suggest testing in these areas.
You may want to convert from a string to an integer for you students here is some
sample code
String conversion using stoi() or atoi()
stoi() : The stoi() function takes a string as an
argument and returns its value. Following is a simple
implementation:
filter_none
edit
play_arrow
brightness_4
// C++ program to demonstrate working of stoi() // Work only if compiler supports C++11 or above. #include <iostream> #include <string> using namespace std;
int main() { string str1 = "45"; string str2 = "3.14159"; string str3 = "31337 geek";
int myint1 = stoi(str1); int myint2 = stoi(str2); int myint3 = stoi(str3);
cout << "stoi(\"" << str1 << "\") is " << myint1 << '\n'; cout << "stoi(\"" << str2 << "\") is " << myint2 << '\n'; cout << "stoi(\"" << str3 << "\") is " << myint3 << '\n';
return 0; } |
Output:
stoi("45") is 45 stoi("3.14159") is 3 stoi("31337 geek") is 31337 Please Note: You may decide that you need a function that returns a 2 character long string given an integer. This is starter code . It does not fully help you in this project you will need to modify or add a bit of stuff to get it to be truly helpful. the statement temp+=number%10+48; could be coded as : temp+=number%10+'0'; Here is some starter code:
string convertInt(int number) { if (number == 0) return "0"; string temp=""; string returnvalue=""; while (number>0) { temp+=number%10+48; number/=10; } for (int i=0;i<temp.length();i++) returnvalue+=temp[temp.length()-i-1]; return returnvalue; }
this is my code from my previous homework:
#include<iostream>
#include<string>
using namespace std;
class Runner
{
private:
string bibnumber;
char gender;
int age;
string name;
string time;
public:
Runner()
{
bibnumber=" ";
gender=' ';
age=0;
name=" ";
time=" ";
}
int getAge()
{
return age;
}
string getName()
{
return name;
}
string getTime()
{
return time;
}
string getBin()
{
return bibnumber;
}
char getGender()
{
return gender;
}
void setCombinedGenderBib ( string bib)
{
gender=bib[0];
bibnumber=bib.substr(1,bib.length());
}
void setName(string name)
{
this->name=name;
}
void setTime(string time)
{
this->time= time;
}
void setAge(int age)
{
this->age= age;
}
};
int main()
{
Runner runner;
runner.setName("john");
runner.setAge(23);
runner.setTime("01:04:37");
runner.setCombinedGenderBib("M4321");
cout<<"Name : "<<runner.getName()<<endl;
cout<<"Bin Number : "<<runner.getBin()<<endl;
cout<<"Age : "<<runner.getAge()<<endl;
cout<<"Gender : "<<runner.getGender()<<endl;
cout<<"Time : "<<runner.getTime()<<endl;
return0;
In: Computer Science
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