IN C++ PLEASE:
(1) Extend the ItemToPurchase class per the following
specifications:
(2) Create three new files:
Build the ShoppingCart class with the following specifications. Note: Some can be function stubs (empty functions) initially, to be completed in later steps.
In: Computer Science
How might you test for possible interface misunderstanding in software? Here “interface misunderstanding" refers to calling functions on an interface with the correct function signatures but with incorrect intent.
pls state what u need. the question is pretty straight
forward.
In: Computer Science
How to write a quick sort using just one recursive call in Java?
In: Computer Science
In: Computer Science
what are the most important things of Audit Policies and Event Viewer in windows?
In: Computer Science
mySQL database question.. I have a database that has the following tables:
User (Id, Name, Gender) Primary key = Id
Friends (Id1, Id2, Startdate) Primary key = (Id1, Id2) Foreign keys are also Id1, Id2 pointing to User(Id)
Comments (CommentId, Poster, Recipient, Text, PostDate) Primary key = (CommentId) Foreign Keys are Poster, Recipient pointing to User(Id)
I need to answer the following queries:
5. List Users who have posted comments to all female users
6. List User(s) who have received comments from the most number of users
When finding users, all I need to list is the Id of the user.
In: Computer Science
Describe how the Liskov Substitution Principle can influence the way that you might implement the Open Closed Principle in software. (Describe how it might help but also how it might constrain implementations of the OCP.)
In: Computer Science
Please SOLVE EXERCISE 4.20
Programming Exercise 3.20 required you to design a PID manager that allocated a unique process identifier to each process.
Exercise 4.20 requires you to modify your solution from Exercise 3.20 by writing a program that creates a number of threads that requested and released process identifiers. Modify your solution to Exercise 4.20 by ensuring that the data structure used to represent the availability of process identifiers is safe from race conditions. Use Pthreads mutex locks.
Please SOLVE EXERCISE 4.20
My Programming Exercise 3.20)
package com.company;
import java.util.HashMap;
/*
dip manager manages process identifiers, which are unique.
Several active processes can not have same pid.
It creates unique pid, which is assigned to ti.
When process completes execution pid is returned to pdd manager.
pdd manager reassigns this pid.
--first method:
creates and initializes the map in order to maintain the list of available pids.
--second method:
finds next avialable pid and assigns them to active processes
--third method:
releases old identifiers by making them available again for new processes.
*/
public class PID_MAP {
/*
Variables that will specify the range of pid values
basically it says that process identifiers are constant
integers (final key word) between 300 and 500.
*/
public static final Integer MIN_PID = 300;
public static final Integer MAX_PID = 5000;
/*
variables that identify availability of a particular process identifier
with 0 being available and 1 being currently in use
*/
public Integer available = 0;
public Integer notAvailable = 1;
/*
I decided to use hash map data structure named PID_map to represent the availability of process identifiers with Key/Value principle
*/
public HashMap PID_map;
/*
int allocate_map(void) - Creates and initializes a data structure for representing pids; returns -1 if unsuccessful and 1 if successful
This method allocates a hash map of possible pid-s.
The map has Key/Value principle.
Key is an Integer, Value is "available (0) /not available (1)" for allocation to an active process.
*/
public int allocate_map(){
//allocated map for certain capacity
PID_map = new HashMap(MAX_PID - MIN_PID + 1); //checks if system has enough resources to allocate a map of the capacity mentioned above
if(true) {
for (int i = MIN_PID; i <= MAX_PID; i++) {
PID_map.put(i, available); //values for all the keys are set to 0, because non of the process will be active if I do not allocate the map first.
}
}
else {
return -1; //if returns integer "-1" means hash map did not created, initialized and allocated successfully.
}
return 1; //if returns integer "1" means hash map successfully created, initialized and allocated.
}
/*Process Synchronization means sharing system resources by processes in a such a way that, Concurrent access to shared data is handled thereby minimizing
the chance of inconsistent data. Thats why we use key word Synchronized.
*/
/*
int allocate_pid(void) - Allocates and returns a pid; returns -1 if if unable to allocate a pid (all pids are in use)
*/
public int allocate_pid(){
for (Integer i = MIN_PID; i <= MAX_PID; i++){ //traverses through the map to find available pid
if (PID_map.get(i).equals(available)){ //once the available process identifier is found
PID_map.put(i,notAvailable); //the process identifier is updated from avialeble to unavialable
return i; //returns the "new unavailable pid"
}
}
return -1; //returs -1 if all process identifiers are in use.
}
/*
void release_pid(int_pid) - Releases a pid.
*/
public void release_pid(Integer k){ // method releases used process identifier which is passes as parameter-Integer K
if(k > MAX_PID || k < MIN_PID){ //double checks if Pid is valid
System.out.println("Error! not valid identifier"); //if not system notifies that its invalid process identifier
}
PID_map.put(k,available); //if it is valid pid, it becomes released and the pid can be used by another process. It is set to available (0)
}
}
/*
DELETED key word SYNCHRONIZED for acllocate_pid() and release_pid() functions
*/
In: Computer Science
Write a program that will search through an array and check to see if the first number in the array occurs more than once. If the first number occurs more than once, return true. Otherwise, return false. If the array is empty, return false?
You will need to use a variable, loop, and if statement.
In: Computer Science
Explain why some people might say that "generalisation" in software design (i.e. designing software so that it can anticipate future evolution) is a "bad smell" (i.e. something that needs to be refactored away)? In your explanation consider arguments for and against generalisation being a “bad smell”.
In: Computer Science
python programming
• Appropriate and well constructed while and/or for loops (as necessary). • Appropriate if, if-else, if-elif-else statements (as necessary). • The use of the ord() and chr() functions (as necessary). • The following three functions (refer to stage 6 for description): o display_details() o get_menu_choice() o get_offset() • Output that strictly adheres to the assignment specifications. If you are not sure about these details, you should check with the ‘Sample Output – Part II’ provided at the end of this document. • Good programming practice: o Consistent commenting, layout and indentation. You are to provide comments to describe: your details, program description, all variable definitions, and significant sections of code. o Meaningful variable names. • Your solutions MAY make use of the following built-in functions and methods: o Any of the Python built-in functions… specifically, you may find you may need the following: int(), input(), print(), range(), ord(),and chr(). • Your solutions MAY ALSO make use of the following: o Concatenation (+) operator to create/build new strings. o Access the individual elements in a string with an index (one element only). i.e. string_name[index]. o Your own (user-defined) functions (in addition to the three functions listed above). Your solutions MUST NOT use: • break, or continue statements in your solution. Do not use the quit() or exit() functions or the break or return statements (or any other techniques) as a way to break out of loops. Doing so will result in a significant mark deduction.
Sample output
*** Menu ***
1. Encrypt string
2. Decrypt string
3. Brute force decryption
4. Quit
What would you like to do [1,2,3,4]? 1
Please enter string to encrypt: Elvis has left the building!
Please enter offset value (1 to 94): 3
Encrypted string: Hoylv#kdv#ohiw#wkh#exloglqj$
*** Menu ***
1. Encrypt string
2. Decrypt string
3. Brute force decryption
4. Quit What would you like to do [1,2,3,4]? 2
Please enter string to decrypt: Hoylv#kdv#ohiw#wkh#exloglqj$ Please enter offset value (1 to 94): 3
Decrypted string: Elvis has left the building!
*** Menu ***
1. Encrypt string
2. Decrypt string
3. Brute force decryption
4. Quit What would you like to do [1,2,3,4]? 3
Please enter string to decrypt: Hoylv#kdv#ohiw#wkh#exloglqj$
Offset: 1 = Decrypted string: Gnxku"jcu"nghv"vjg"dwknfkpi# Offset: 2 = Decrypted string: Fmwjt!ibt!mfgu!uif!cvjmejoh" Offset: 3 = Decrypted string: Elvis has left the building! Offset: 4 = Decrypted string: Dkuhr~g`r~kdes~sgd~athkchmf Offset: 5 = Decrypted string: Cjtgq}f_q}jcdr}rfc}`sgjbgle~ Offset: 6 = Decrypted string: Bisfp|e^p|ibcq|qeb|_rfiafkd} Offset: 7 = Decrypted string: Ahreo{d]o{habp{pda{^qeh`ejc| Offset: 8 = Decrypted string: @gqdnzc\nzg`aozoc`z]pdg_dib{ Offset: 9 = Decrypted string: ?fpcmyb[myf_`nynb_y\ocf^chaz Offset: 10 = Decrypted string: >eoblxaZlxe^_mxma^x[nbe]bg`y Offset: 11 = Decrypted string: =dnakw`Ykwd]^lwl`]wZmad\af_x Offset: 12 = Decrypted string: P\IBCQ\QEB\?RFIAFKD] Offset: 39 = Decrypted string: !HREO[D=O[HABP[PDA[>QEH@EJC\ Offset: 40 = Decrypted string: GQDNZCCHAZ Offset: 42 = Decrypted string: }EOBLXA:LXE>?MXMA>X;NBE=BG@Y Offset: 43 = Decrypted string: |DNAKW@9KWD=>LWL@=W:MADW Offset: 45 = Decrypted string: zBL?IU>7IUB;;U8K?B:?D=V Offset: 46 = Decrypted string: yAK>HT=6HTA:;ITI=:T7J>A9>CH;EQ:3EQ>78FQF:7Q4G;>6;@9R Offset: 50 = Decrypted string: u=G:DP92DP=67EPE96P3F:=5:?8Q Offset: 51 = Decrypted string: t7P Offset: 52 = Decrypted string: s;E8BN70BN;45CNC74N1D8;38=6O Offset: 53 = Decrypted string: r:D7AM6/AM:34BMB63M0C7:27<5N Offset: 54 = Decrypted string: q9C6@L5.@L923ALA52L/B6916;4M Offset: 55 = Decrypted string: p8B5?K4-?K812@[email protected]:3L Offset: 56 = Decrypted string: o7A4>J3,>J701?J?30J-@47/492K Offset: 57 = Decrypted string: n6@3=I2+=I6/0>I>2/I,?36.381J Offset: 58 = Decrypted string: m5?2
25-270I Offset: 59 = Decrypted string: l4>1;G0);G4-.' 2>+$%3>3'$>!4(+#(-&? Offset: 69 = Decrypted string: b*4'1=&~1=*#$2=2= 3'*"',%> Offset: 70 = Decrypted string: a)3&0<%}0<)"#1<1%"<~2&)!&+$= Offset: 71 = Decrypted string: `(2%/;$|/;(!"0;0$!;}1%( %*#< Offset: 72 = Decrypted string: _'1$.:#{.:' !/:/# :|0$'~$)"; Offset: 73 = Decrypted string: ^&0#-9"z-9&~ .9."~9{/#&}#(!: Offset: 74 = Decrypted string: ]%/",8!y,8%}~-8-!}8z."%|"' 9 Offset: 75 = Decrypted string: \$.!+7 x+7$|},7, |7y-!${!&~8 Offset: 76 = Decrypted string: [#- *6~w*6#{|+6+~{6x, #z %}7 Offset: 77 = Decrypted string: Z",~)5}v)5"z{*5*}z5w+~"y~$|6 Offset: 78 = Decrypted string: Y!+}(4|u(4!yz)4)|y4v*}!x}#{5 Offset: 79 = Decrypted string: X *|'3{t'3 xy(3({x3u)| w|"z4 Offset: 80 = Decrypted string: W~){&2zs&2~wx'2'zw2t({~v{!y3 Offset: 81 = Decrypted string: V}(z%1yr%1}vw&1&yv1s'z}uz x2 Offset: 82 = Decrypted string: U|'y$0xq$0|uv%0%xu0r&y|ty~w1 Offset: 83 = Decrypted string: T{&x#/wp#/{tu$/$wt/q%x{sx}v0 Offset: 84 = Decrypted string: Sz%w".vo".zst#.#vs.p$wzrw|u/ Offset: 85 = Decrypted string: Ry$v!-un!-yrs"-"ur-o#vyqv{t. Offset: 86 = Decrypted string: Qx#u ,tm ,xqr!,!tq,n"uxpuzs- Offset: 87 = Decrypted string: Pw"t~+sl~+wpq + sp+m!twotyr, Offset: 88 = Decrypted string: Ov!s}*rk}*vop~*~ro*l svnsxq+ Offset: 89 = Decrypted string: Nu r|)qj|)uno})}qn)k~rumrwp* Offset: 90 = Decrypted string: Mt~q{(pi{(tmn|(|pm(j}qtlqvo) Offset: 91 = Decrypted string: Ls}pz'ohz'slm{'{ol'i|pskpun( Offset: 92 = Decrypted string: Kr|oy&ngy&rklz&znk&h{orjotm' Offset: 93 = Decrypted string: Jq{nx%mfx%qjky%ymj%gznqinsl& Offset: 94 = Decrypted string: Ipzmw$lew$pijx$xli$fymphmrk%
*** Menu ***
1. Encrypt string
2. Decrypt string
3. Brute force decryption
4. Quit What would you like to do [1,2,3,4]? 4 Goodbye.
Note: Your program must work with the printable ASCII character set. That is, all the characters from ASCII 32 (Space) to ASCII 126 (~). When the offset points to a character beyond 126 it should wrap around to the beginning of the set.
In: Computer Science
Homework Assignment 4 Instructions: Class name must be: HW4_yourName For example: Michael will name the class of homework assignment 4 as HW4_Michael Grading Rubric: Code running and as per the required conditions and giving expected output = 10 points File named as per instructions = 1 point Comments in code = 4 points Problem: Average calculation for a list Write a program that reads a text file named test_scores.txt to read the name of the student and his/her scores for 3 tests. The program should display class average for first test (average of scores of test 1) and average (average of 3 tests) for each student. Expected Output: ['John', '25', '26', '27'] ['Michael', '24', '28', '29'] ['Adelle', '23', '24', '20'] [['John', '25', '26', '27'], ['Michael', '24', '28', '29'], ['Adelle', '23', '24', '20']] Class average for test 1 is: 24.0 Average for student John is 26.00 Average for student Michael is 27.00 Average for student Adelle is 22.33
In: Computer Science
Implement C++ program for each of the following.
Let D = [-48, -14, -8, 0, 1, 3, 16, 23, 26, 32, 36] Each answer is
either True or False. If False, give example
of number(s) that make it False. i.e. The Counterexample. ∀x∈D, if
x is odd then x > 0
Let D = [-48, -14, -8, 0, 1, 3, 16, 23, 26, 32, 36] Each answer is
either True or False. If False, give example
of number(s) that make it False. i.e. The Counterexample. ∀x∈D, if
x is less than 0 then x is even.
Let D = [-48, -14, -8, 0, 1, 3, 16, 23, 26, 32, 36] Each answer is
either True or False. If False, give example
of number(s) that make it False. i.e. The Counterexample. ∀x∈D, if
x is even then x <= 0;
Let D = [-48, -14, -8, 0, 1, 3, 16, 23, 26, 32, 36] Each answer is
either True or False. If False, give example
of number(s) that make it False. i.e. The Counterexample. ∀x∈D, if
the ones digit of x is 2, then the tens
digit is 3 or 4.
Let D = [-48, -14, -8, 0, 1, 3, 16, 23, 26, 32, 36] Each answer is
either True or False. If False, give example
of number(s) that make it False. i.e. The Counterexample. ∀x∈D, if
the ones digit of x is 6, then the tens
digit is 1 or 2.
In: Computer Science
Recursion.
Question 1
1.1 What are the 2 main components of a recursive function?
1.2 What is more efficient: an explicit loop structure or a recursive function? Explain your answer.
1.3 In what scenarios should a recursive solution be preferred to an iterative solution?
In: Computer Science
Write a program that has a function (named getNumStats()) that will return a string that has stats on the number entered.
The prototype is:
string getNumStats(double);
The stats are:
Is the number an integer or a double?
The polarity (is it positive or negative; 0 counts as positive)
The parity (is it odd or even)
Is it a prime number? (for this program, 1 is considered a prime number)
For example, if the following lines of code are executed
double dNum = 14.06;
string test = getNumStats(dNum)
cout << test << endl;
The output that appears on the screen will be:
14.06 is a double
It is positive
It does not have parity
It is not a prime number
Another run is:
double dNum = -27.371;
string test = getNumStats(dNum)
cout << test << endl;
The output that appears on the screen will be:
-23.371 is a double
It is negative
It does not have parity
It is not a prime number
Note: your first line of output may or may not show trailing zeros. You may add that feature to always show zeros (even if the number is an integer)
In: Computer Science