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
Describe astroturfing and its impacts on the reliability of online reviews .
Describe how you would determine if a review concerning a startup is legitimate or a fraud .
Feel free to make references.
In: Computer Science
Why is it important for a project to have a clearly defined
scope statement all parties agree with?
What can happen if the project scope is not clearly defined and not
agreed to by all parties?
Give us examples in which project scope was not clearly defined and
explain what could be done differently.
In: Computer Science
Task in this assignment is to write mips_sim a simulator for a small simple subset of the MIPS .
The input to mips_sim will be the 32-bit instruction codes for MIPS instructions as hexadecimal numbers.
mips_sim.c should simulate executing these instruction like this:
cat examples/42.hex 3404002a 34020001 c 3404000a 3402000b c dcc mips_sim.c -o mips_sim ./mips_sim examples/42.hex 0: 0x3404002A ori $4, $0, 42 >>> $4 = 42 1: 0x34020001 ori $2, $0, 1 >>> $2 = 1 2: 0x0000000C syscall >>> syscall 1 <<< 42 3: 0x3404000A ori $4, $0, 10 >>> $4 = 10 4: 0x3402000B ori $2, $0, 11 >>> $2 = 11 5: 0x0000000C syscall >>> syscall 11 <<<
A reference implementation is available as 1521 mips_sim which can use to find the correctoutput for any input, like this:
cat examples/square.hex 34100004 34110003 72108002 72318802 2302020 34020001 c 3404000a 3402000b c 1521 mips_sim examples/square.hex 0: 0x34100004 ori $16, $0, 4 >>> $16 = 4 1: 0x34110003 ori $17, $0, 3 >>> $17 = 3 2: 0x72108002 mul $16, $16, $16 >>> $16 = 16 3: 0x72318802 mul $17, $17, $17 >>> $17 = 9 4: 0x02302020 add $4, $17, $16 >>> $4 = 25 5: 0x34020001 ori $2, $0, 1 >>> $2 = 1 6: 0x0000000C syscall >>> syscall 1 <<< 25 7: 0x3404000A ori $4, $0, 10 >>> $4 = 10 8: 0x3402000B ori $2, $0, 11 >>> $2 = 11 9: 0x0000000C syscall >>> syscall 11 <<<
You need to implement only these 10 MIPS instructions:
Assembler | C | Bit Pattern |
---|---|---|
add $d, $s, $t | d = s + t | 000000ssssstttttddddd00000100000 |
sub $d, $s, $t | d = s - t | 000000ssssstttttddddd00000100010 |
slt $d, $s, $t | d = s < t | 000000ssssstttttddddd00000101010 |
mul $d, $s, $t | d = s * t | 011100ssssstttttddddd00000000010 |
beq $s, $t, I | if (s == t) PC += I | 000100ssssstttttIIIIIIIIIIIIIIII |
bne $s, $t, I | if (s != t) PC += I | 000101ssssstttttIIIIIIIIIIIIIIII |
addi $t, $s, I | t = s + I | 001000ssssstttttIIIIIIIIIIIIIIII |
ori $t, $s, I | t = s | I | 001101ssssstttttIIIIIIIIIIIIIIII |
lui $t, I | t = I << 16 | 00111100000tttttIIIIIIIIIIIIIIII |
syscall | syscall | 00000000000000000000000000001100 |
You only need to implement these 3 system calls.
Description | $v0 | Pseudo-C |
---|---|---|
print integer | 1 | printf("%d", $a0) |
exit | 10 | exit(0) |
print character | 11 | printf("%c", $a0) |
Task is to add code under execute_instructions function and
necessary additional functions.
// starting point code
// PUT YOUR HEADER COMMENT HERE
#include
#include
#include
#include
#include
#define MAX_LINE_LENGTH 256
#define INSTRUCTIONS_GROW 64
// ADD YOUR #defines HERE
void execute_instructions(int n_instructions,
uint32_t instructions[n_instructions],
int trace_mode);
char* process_arguments(int argc, char* argv[], int*
trace_mode);
uint32_t* read_instructions(char* filename, int*
n_instructions_p);
uint32_t* instructions_realloc(uint32_t* instructions, int
n_instructions);
// ADD YOUR FUNCTION PROTOTYPES HERE
// YOU SHOULD NOT NEED TO CHANGE MAIN
int main(int argc, char* argv[]) {
int trace_mode;
char* filename = process_arguments(argc, argv,
&trace_mode);
int n_instructions;
uint32_t* instructions = read_instructions(filename,
&n_instructions);
execute_instructions(n_instructions, instructions, trace_mode);
free(instructions);
return 0;
}
// simulate execution of instruction codes in instructions
array
// output from syscall instruction & any error messages are
printed
//
// if trace_mode != 0:
// information is printed about each instruction as it
executed
//
// execution stops if it reaches the end of the array
void execute_instructions(int n_instructions,
uint32_t instructions[n_instructions],
int trace_mode) {
// REPLACE CODE BELOW WITH YOUR CODE
int pc = 0;
while (pc < n_instructions) {
if (trace_mode) {
printf("%d: 0x%08X\n", pc, instructions[pc]);
}
pc++;
}
}
// ADD YOUR FUNCTIONS HERE
// YOU DO NOT NEED TO CHANGE CODE BELOW HERE
// check_arguments is given command-line arguments
// it sets *trace_mode to 0 if -r is specified
// *trace_mode is set to 1 otherwise
// the filename specified in command-line arguments is returned
char* process_arguments(int argc, char* argv[], int* trace_mode)
{
if (
argc < 2 ||
argc > 3 ||
(argc == 2 && strcmp(argv[1], "-r") == 0) ||
(argc == 3 && strcmp(argv[1], "-r") != 0)) {
fprintf(stderr, "Usage: %s [-r] \n", argv[0]);
exit(1);
}
*trace_mode = (argc == 2);
return argv[argc - 1];
}
// read hexadecimal numbers from filename one per line
// numbers are return in a malloc'ed array
// *n_instructions is set to size of the array
uint32_t* read_instructions(char* filename, int*
n_instructions_p) {
FILE* f = fopen(filename, "r");
if (f == NULL) {
fprintf(stderr, "%s: '%s'\n", strerror(errno), filename);
exit(1);
}
uint32_t* instructions = NULL;
int n_instructions = 0;
char line[MAX_LINE_LENGTH + 1];
while (fgets(line, sizeof line, f) != NULL) {
// grow instructions array in steps of INSTRUCTIONS_GROW
elements
if (n_instructions % INSTRUCTIONS_GROW == 0) {
instructions = instructions_realloc(instructions, n_instructions +
INSTRUCTIONS_GROW);
}
char* endptr;
instructions[n_instructions] = strtol(line, &endptr, 16);
if (*endptr != '\n' && *endptr != '\r' && *endptr
!= '\0') {
fprintf(stderr, "%s:line %d: invalid hexadecimal number: %s",
filename, n_instructions + 1, line);
exit(1);
}
n_instructions++;
}
fclose(f);
*n_instructions_p = n_instructions;
// shrink instructions array to correct size
instructions = instructions_realloc(instructions,
n_instructions);
return instructions;
}
// instructions_realloc is wrapper for realloc
// it calls realloc to grow/shrink the instructions array
// to the speicfied size
// it exits if realloc fails
// otherwise it returns the new instructions array
uint32_t* instructions_realloc(uint32_t* instructions, int
n_instructions) {
instructions = realloc(instructions, n_instructions * sizeof *
instructions);
if (instructions == NULL) {
fprintf(stderr, "out of memory");
exit(1);
}
return instructions;
}
In: Computer Science
Code in python:
In: Computer Science
If you were assigned to select between EIGRP and OSPF for your company, which one would you recommend and why? How would you convince the management team?
In: Computer Science
Must be in C++ (beginners coding class)
8.
a. Rewrite the definition of the class complexType so that the arith-metic and relational operators are overloaded as nonmember functions.
b. Write the definitions of the member functions of the class complexType as designed in part a.
c. Write a test program that tests various operations on the class complexType as designed in parts a and b. Format your answer with two decimal places.
(additional info/problem ) does not need to be answered only number 8 needs to be answered
a. Extend the definition of the class complexType so that it performs the subtraction and division operations. Overload the operators subtrac-tion and division for this class as member functions.
If (a, b) and (c, d ) are complex numbers:
(a, b)-(c, d )=(a - c, b - d ).
If (c, d ) is nonzero:
(a, b)/(c, d)=((ac + bd )/(c2+ d2), (-ad + bc)/(c2+ d2)).
b. Write the definitions of the functions to overload the operators - and / asdefined in part a.
c. Write a test program that tests various operations on the classcomplexType. Format your answer with two decimal places.
In: Computer Science
Discrete Math Problems:
ALGORITHM 2 The Linear Search Algorithm.
procedure linear search(x: integer, a1, a2,…, an: distinct integers)
i := 1
while (i ≤ n and x ≠ ai)
i := i + 1
if i ≤ n then location := i
else location := 0
return location{location is the subscript of the term that equals x, or is 0 if x is not found}
// input to algorithm is n, an integer
j := n;
while( j>= 1 )
{
for i := 1 to j
{
x := x + 1;
}
j := floor ( j/2 );
}
In: Computer Science
Q) Explain two factors that may affect the IT project cost estimation using your own words. Support your answer with examples.
In: Computer Science
FILE *fin = NULL;
fin = fopen(in.txt, "r");
int *arr = (int *) malloc (sizeof (int) * fin);
*****************************************************
If I want to open a in.txt, only the integer in the file, is the malloc code correct?
What if the in.txt includes the string and integer, how can I use the malloc?
Thanks
In: Computer Science
Q)
You are the manager of a project to build a data centre with the following characteristics:
• The project team has to install one server a week for three months.
• The project is scheduled to last for three months.
• The total budget for this project is SAR 60,000
• Each server is planned to cost SAR 5,000.
Answer the succeeding questions based on the following information:
In: Computer Science
Q)
Use your own words to describe four different ways used to develop a project WBS briefly. Then, explain why it is often so difficult to create a good WBS?
In: Computer Science
Design and implement a method that will take any value as String (even it's a number!) and convert that value to a number in any base. Use the method;
private static ArrayList convertToBase(String value, int currentBase, int targetBase){
// your algorithm
return result; //which is a String array
}
Examples:
convertToBase("10011", 2, 10) should return [1, 9], meaning,
(10011)base2 = (19)base10
convertToBase("100", 10, 8) should return [6, 4]
convertToBase("E12B0", 16, 2) should return [1,1,1,0,0,0,0,1,0,0,1,0,1,0,1,1,0,0,0,0]
convertToBase("1250", 10, 16) should return [4, E, 2]
Write a tester, make sure your code produces correct results.
i am using blue j / java, can you please provide a solution for the above with explaining comments
thank you
In: Computer Science
It is very important about how you craft your organization's security policies with your organization.
Your policy should comprehensively address all the main security vulnerabilities and risks within your organization.
Remember your overall security policy, not all covers computers, internet, applications, servers, user access, etc.. but many other areas which we will delve into. Attached is a sample acceptable use policy from the SANS Institute.
What sections really stand out to you and why?
In: Computer Science