In: Computer Science
Write a C++ program that displays the numbers between 1000 and 9999, which are divisible by sum of the digits in them. For example, 2924 is divisible by (2+9+2+4 = 17). Your program should display all these possible numbers in the given range, and each number should be separated from the other by a space.
In: Computer Science
Implement the steffenson method in matlab. The code must be in MATLAB
DOnt answer if you cannot give correct
MATLAB
In: Computer Science
All questions in this assignment refer to the “om” database (or Schema) that you will find in your MySQL Workbench program if you have run the sample database install script.
Please save all of your answers in one script (.sql) or type all your answers into Notepad++ and submit them as a single .sql file. You are encouraged to test your SQL statements in Workbench, and please use the ‘tidy’ tool to properly format your SQL before you save it as a Script from Workbench or Notepad++. Use comments to indicate the question number for each answer. Please give all code. Don't give same like other code. Please do with error free.
1. Write a SELECT statement that returns the title, artist and unit_price columns from the items table. Return only those items that have a unit_price of at least $16, but less than $17.50
2. Write a SELECT statement to return all columns from the customers table where the customer’s state is Ohio (OH). Sort the results by last name in descending order.
3. Write a SELECT statement to return all columns from the customers table whose zip code begins with a “9”
4. Write a SELECT statement to return the order_id from the orders table where the number of days between the order_date and the shipped_date is less than 6
5. Expand the statement in question 4 to include the number of days between order and ship date as a column alias called ‘processing_days’ and sort the results by that column in ascending order
In: Computer Science
Can explain process states, concept of process scheduling, context switch, and process table
In: Computer Science
Part 1 Write a program that displays a frame containing two labels that display your name, one for your first name and one for your last. Experiment with the size of the window to see the labels change their orientation to each other. USE FIRST NAME: Aya LAST NAME: KAYED. SEND THE CODE IN THE EXACT FORMAT FOR JAVA ECLIPSE. I WILL COPY AND PASTE THE CODE SO I CAN RUN IT. Part 2 Propose and solve your own digital design problem.
In: Computer Science
In: Computer Science
Malicious software can be classified by propagation method or payload. Explain the difference between the three common propagation methods: worm, virus and social engineering;
Explain the difference between a normal virus, a metamorphic virus and a polymorphic virus, including discussing how easy they are to detect by anti-virus software
In: Computer Science
Implement the working of a mohr circle in matlab. ask user to enter the stresses in x and y direction. take the inputs to a stress tensor. then use formulations to find the eigen value and vectors.
MATLAB
In: Computer Science
Build a simple list implementation that uses arrays to store the values. Create a class SimpleArrayList with a public constructor that initializes the list using a passed array of Object references. Assert that the passed array is not null. Next, implement:
1)Object get(int), which takes an int index and returns the Object at that index
2)void set(int, Object), which takes an int index and an object reference and sets that value at the index to the passed reference
Both your get and set method should assert that index passed is valid for that SimpleArrayList.
Here's an example how your code should work
SimpleArrayList list = new SimpleArrayList(new int[] {1,2,5});
System.out.println(list.get(1)); //prints 2 list.set(1,6);
System.out.println(list.get(1)); //prints 6
System.out.println(list.get(0)); //prints 1
System.out.println(list.get(4)); //generates an assertion error
Note: shouldn't be using java.util.List for the question
In: Computer Science
Files and folders; we all use them today on our varying computer devices.
1. State briefly what you understand a file extension to be and what its purpose is.
2. Identify three file extensions that you see and which software applications may have created them.
3. Reason to have our files and folders properly managed.
Formulate your discussion points/posting comprising 400 – 600 words based on the above questions
In: Computer Science
I want the code below to be edited:
Rather than giving the input string inside the code, I want the
program to ask the user for an input and calculate and complete
this code.
I have pasted the actual code below, Please edit the input section
only so that I can input any string or any sentence as I like. The
program must ask the user that "Enter a
string/sentence" and take the data to calculate the
Huffman code.
#include <bits/stdc++.h> #define MAX_TREE_HT 256 using namespace std; map<char, string> codes; map<char, int> freq; struct MinHeapNode { char data; int freq; MinHeapNode *left, *right; MinHeapNode(char data, int freq) { left = right = NULL; this->data = data; this->freq = freq; } }; struct compare { bool operator()(MinHeapNode* l, MinHeapNode* r) { return (l->freq > r->freq); } }; void printCodes(struct MinHeapNode* root, string str) { if (!root) return; if (root->data != '$') cout << root->data << ": " << str << "\n"; printCodes(root->left, str + "0"); printCodes(root->right, str + "1"); } void storeCodes(struct MinHeapNode* root, string str) { if (root==NULL) return; if (root->data != '$') codes[root->data]=str; storeCodes(root->left, str + "0"); storeCodes(root->right, str + "1"); } priority_queue<MinHeapNode*, vector<MinHeapNode*>, compare> minHeap; void HuffmanCodes(int size) { struct MinHeapNode *left, *right, *top; for (map<char, int>::iterator v=freq.begin(); v!=freq.end(); v++) minHeap.push(new MinHeapNode(v->first, v->second)); while (minHeap.size() != 1) { left = minHeap.top(); minHeap.pop(); right = minHeap.top(); minHeap.pop(); top = new MinHeapNode('$', left->freq + right->freq); top->left = left; top->right = right; minHeap.push(top); } storeCodes(minHeap.top(), ""); } void calcFreq(string str, int n) { for (int i=0; i<str.size(); i++) freq[str[i]]++; } string decode_file(struct MinHeapNode* root, string s) { string ans = ""; struct MinHeapNode* curr = root; for (int i=0;i<s.size();i++) { if (s[i] == '0') curr = curr->left; else curr = curr->right; if (curr->left==NULL and curr->right==NULL) { ans += curr->data; curr = root; } } return ans+'\0'; } int main() { string str = "Please remove this input and help me put my own input into the program"; string encodedString, decodedString; calcFreq(str, str.length()); HuffmanCodes(str.length()); cout << "Character With there Frequencies:\n"; for (auto v=codes.begin(); v!=codes.end(); v++) cout << v->first <<' ' << v->second << endl; for (auto i: str) encodedString+=codes[i]; cout << "\nEncoded Huffman data:\n" << encodedString << endl; decodedString = decode_file(minHeap.top(), encodedString); cout << "\nDecoded Huffman Data:\n" << decodedString << endl; return 0; }
In: Computer Science
Write a program where a user of this program will play a game in which he/she needs to guess a target number, which is a number that the program has randomly picked in the range that the user chooses. The program will repeatedly prompt for the guessed number and provide a clue whether the guessed number is bigger or smaller than the target number, until the guessed number equals the target number.
In: Computer Science
A 10-character password is to be selected from an alphabet comprised of the following: all lower case and upper case English alphabet and all numbers. Compute the entropy of such a password. Why would such an entropy computation not be representative of passwords in practical settings?
In: Computer Science
Programming Assignment 5
Your work on the last project, the inventory ordering system, was so well received that your boss has asked you to write a new program for the firm. She mentions that she’s heard a lot about “Object Oriented Programming” and wants you to create a database of part’s suppliers that the company will use to source new inventory from. She mentions that there have been a lot of new entrants into the market and its important that you source the new widgets and sprockets at the best cost possible! From speaking with her you realize that you’ll need three new class definitions – a class that models a supplier, a class that represents a part, and class that will contain information about all these suppliers.
The parts class will need to contain the following information:
1. Part name
2. Part cost
The parts class will need to contain the following methods:
1. An init method that lets the user set the name and cost of the part
The supplier class will need to contain the following information:
1. The company name
2. A list of the parts the company supplies
The supplier class will need the following methods:
1. An init method to set the company name
2. A method that lets the user add a part to the list of parts a company supplies
3. A method that takes a part argument and returns the cost of that part.
4. A method that takes a part argument and returns a Boolean if the part is supplied by the company (True if it does, False if it does not).
The database class will need the following data:
1. A list of suppliers
The database class will need the following methods:
1. An init method to initialize the database
2. A method to add a supplier
3. A method to find the lowest cost for a part. The input will be a part name, and the output will be two values: the name of the supplier, and the cost. If the part is not sold by any suppliers, return False, False. Unlike in other programs – you do not need to write the code for user input, input validation, or output – you need only to write the classes! The company has supplied the program to load in the data and get the data from the classes, you need only to define the classes (and test with the supplied program of course)!
Sample Input/Output
Enter supplier name, or quit to exit: World Parts, Inc
Part info should be entered in the following format: name, price
Enter part info, or quit to exit: gizmo, 1.99
Enter part info, or quit to exit: sprocket, 3.12
Enter part info, or quit to exit: quit
Enter supplier name, or quit to exit: ABC Manufacturing
Part info should be entered in the following format: name, price
Enter part info, or quit to exit: sprocket, 3.09
Enter part info, or quit to exit: gizmo, 2.34
Enter part info, or quit to exit: dodad, 13.99
Enter part info, or quit to exit: quit
Enter supplier name, or quit to exit: quit
Supplier database complete!
Please enter in a part name or quit to exit: gizmo
Part gizmo is available for the best price at World Parts, Inc. Price: $1.99
Please enter in a part name or quit to exit: sprocket
Part sprocket is available for the best price at ABC Manufacturing. Price: $3.09
Please enter in a part name or quit to exit: dodad
Part dodad is available for the best price at ABC Manufacturing. Price: $13.99
Please enter in a part name or quit to exit: quit T
hank you for using the price database!
Additional requirements
1. You MUST use modules, you need to write your 3 classes in 3 separate Python files named database.py, part.py and supplier.py
2. Do NOT modify the supplied Python code – I will test your files with my own Python code – if you have to change the provided Python code to get your classes to work, you’ll lose points.
3. Submit only the 3 python files – part.py, supplier.py and database.py
4. Each Python file must have a program header!
Tips
1. The provided code does all the input/output for this program. You only need to write the code for the 3 classes.
2. Some of the methods for the 3 classes need to be of a specific format or the supplied program will not work – these are the init methods for Suppler and Database, and add_part, add_supplier, and find_part. Make sure you have those methods defined in your program and that their signature matches what the provided code expects.
3. Write the classes from simple to more complex – start with Part, then Supplier, then Database.
The following is a sample code
import database
import supplier
import part
supplier_database = database.Database()
while True:
data = input("Enter supplier name, or quit to exit: ")
if data == "quit":
break
s = supplier.Supplier(data)
print("Part info should be entered in the following format: name, price")
while True:
part_info = input("Enter part info, or quit to exit: ")
if part_info == "quit":
print()
break
try:
name, price = part_info.split(",")
price = float(price)
except:
print("Error input - Part info should be entered in the following format: name, price - please try again")
continue
s.add_part(name, price)
supplier_database.add_supplier(s)
print("\n\nSupplier database complete!\n")
while True:
data = input("Please enter in a part name or quit to exit: ")
if data == "quit":
break
supplier, price = supplier_database.find_part(data)
if supplier == False:
print("Error part does not exist in database")
else:
print(f"Part {data} is available for the best price at {supplier}. Price: ${price:.2f}")
print("\nThank you for using the price database!")
In: Computer Science