Write a function matchSuit() that simulates repeatedly drawing a pair of playing cards from a shuffled deck (of 52 cards) until the pair of cards share the same suit (or you run out of cards). The function should return the total number of cards drawn. Use a while loop. To draw each card, call the drawCard function you wrote above.
In: Computer Science
Choose one of the following cryptography techniques and implement it using any programming language you prefer. Your program should provide the user with two options Encryption and Decryption, with a simple UI to get the input from the user, and view the result. You can use any restriction you need for the user input but you need to clarify that and validate the user input base on your restriction.
● Feistel
● Keyword columnar
● Any cryptosystem of your choice (needs to be approved by the instructor)
Notes:
In: Computer Science
There is a Java program that is missing one recursive function:
public class GCD {
/* There is a neat trick with recursive programming. The function described
* below requires that y is at most x. Rather than add this to the recursive
* function definition, we can add a front-end, helper function.
*
* I wrote this function for you and I called it gcd. The recursive logic goes
* in a function called gcd_rec. All gcd does is make sure that x is not
* smaller than y.
*/
/* Requires x >= y
* / x when y is 0
* gcd(x,y) = |
* \ gcd(y, x%y) otherwise
*/
public static int gcd_rec(int x, int y) {
return 0;
}
public static int gcd(int x, int y) {
if(x < y)
return gcd_rec(y,x);
else
return gcd_rec(x,y);
}
/* Greatest Common Divisor Test Framework
*/
public static void main(String[] args) {
int[] inputX = {10, 35, 14, 4181};
int[] inputY = { 8, 15, 35, 6765};
int[] expect = { 2, 5, 7, 1};
boolean error = false;
assert(inputY.length == inputX.length);
for(int i = 0 ; i < inputX.length; i++) {
int answer = gcd(inputX[i], inputY[i]);
if(answer != expect[i]) {
System.out.printf("ERROR: gcd(%d,%d) returned %d not %d.\n",
inputX[i], inputY[i], answer, expect[i]);
error = true;
}
}
if(error)
System.exit(1);
else
System.out.println("Good Job!");
}
}
In: Computer Science
In: Computer Science
course: routing and switching
5. Configure redistribution using valid routing protocols
Cisco network
Objectives
This assessment task requires you to demonstrate your knowledge of
basic Routing Redistribution concepts by completing a number of
exercise questions.
5. Configure redistribution using valid routing
protocols
course Cisco network *
In: Computer Science
Part 1 - Java program named MemoryCalculator
In your Ubuntu VM (virtual machine), using terminal mode ONLY, do the following:
Create the folder program2
Each record in this file represents the possible location of an error found in RAM. (Hint: One of them is not on one of the chips.)
Assume you have a computer with 4 gigs of RAM, each gig in a different memory chip, therefore you have 4 one gig RAM chips.
---------decimal---------------
HINT:
RAM chip 0 contain addresses: 0 - 8,589,934,584 bits
RAM chip 1 contain addresses: 8,589,934,585 - 17,179,869,184 bits
RAM chip 2 contain addresses: 17,179,869,185 - 25,769,803,768 bits
RAM chip 3 contain addresses: 25,769,803,769 - 34,359,738,368 bits
HINT:
RAM chip 0 contain addresses: 0 - 1,073,741,823 bytes
RAM chip 1 contain addresses: 1,073,741,824 - 2,147,483,648 bytes
RAM chip 2 contain addresses: 2,147,483,647 - 3,221,225,471 bytes
RAM chip 3 contain addresses: 3,221,225,472 - 4,294,967,296 bytes
In the same folder, in terminal mode using an editor, create a Java program to do the following:
- Call the Java program – MemoryCalculator.java
- Open the RAMerrors file
- Read each record
- Print the RAM memory chip where the error is located for each record
*** CREATE YOUR OWN METHODS THAT WILL CONVERT
HEX TO BINARY AND BINARY TO DECIMAL
*** DO NOT USE JAVA'S AUTOMATIC CONVERSION METHODS
Part 2 - Linux Shell Scripting
- Create a sh file named: program2.sh
- Set the permissions for this this *.sh file using this command to make it executable: chmod 755 program2.sh
- program2.sh should add your name and the current date and time to a NEW file called results.txt -program2.sh should then do the following:
How: - Ask the user to enter a number.
- Verify that the number is between 1 and 50, inclusive.
- If the number is not between 1 and 50, then keep asking the user to enter a number until it is valid.
- Use a loop from 1 to the value entered by the user
- Sum the results of all the included numbers, but do not include any output yet.
- After the loop ends, display the sum and append it to the results.txt file on a new line as follows
Sum of numbers is xxx
The results.txt file should have 3 lines in it when done.
***** Primarily need help with the java program *****
In: Computer Science
identify the syntax errors in the following code:
public class Hello {
private static int main(String [] args) {
string Msg=”Hello, Wrld!;
Sytem.out.println(msg+ “Ken")
In: Computer Science
Java
Write a menu driven program that implements the following linked
list operations :
In: Computer Science
which statements are true about Python functions?
a)Different functions cannot use same function name
b)a function always returns some value
c)different function cannot use the same variable names
d) function must use the same parameter names as the corresponding variables in the caller
what benefits does structuring a program through defining functions bring?
a) there is a possibility of reducing the number of variables and/or objects that must be managed at any cost at any one point
b)the program is easier to maintain
c)program with function executes faster
d)the program is easier to debug
in which scenario(s) should the sentinel value be set to -1 to terminate data entry
a)exam scores which can be negative but cannot be more than 100
b) participant name of participants who registered for a run
c)the rainfall data for days it rained
d)the weight of student waiting to undergo a medical examination.
suppose d = {"a": "apple", "b": "banana", "c": "cherry"}
which statement form a list [["a": "apple"], ["b": "banana"[, ["c": "cherry"]]
a) [[k,d[k]] for k in d.keys() ]
b) [[k,v] for k, v in d.items() ]
c) [[d,v] for v in d.values() ]
d) [[k,[0]], k[1]] for k in d]
In: Computer Science
In: Computer Science
In: Computer Science
What are the errors in this code?
//1.
//Filename: CarbonFootprintTest.java
//The file tests the Car class and CarbonFootprint class
public class CarbonFootprintTest {
public static void main (String [] args) {
CarbonFootprint[] obj = new
CarbonFootprint[2];
obj[0] = new CarbonFootprint(20);
obj[1] = new Car(30);
System.out.println("Carbon Foot Print for
each item (lbs):\n");
//additional info for to give general idea of
program
for (CarbonFootprint test: obj)
test.getCarbonFootprint();
}//end main method
}//end class
//2. Filename: CarbonFootprint.java It only include
s one abstract method
public class CarbonFootprint {
//returns the carbon footprint of an
object
public void GetCarbonFootprint();
}//end interface
//3. Filename: Car.java
public class Car extends CarbonFootprint {
private double gallons;
public Car( double g ){
gallons = g;
} // end Car constructor
// one gallon of gas yields 20 pounds of CO2
public abstract void
GetCarbonFootprint(){
System.out.printf( "Car that has
used %.2f gallons of gas: %.2f\n",
gallons,
gallons * 20 );
} // end function GetCarbonFootprint
} // end class Car
In: Computer Science
Using a vending machine requires instructions from the person buying an item and the machine dispensing the item. Using terms and concepts learned this week, discuss the following activities.
What actions by either the person buying an item or the vending machine would you describe as a privilege or non-privileged instructions? Why?
Relate memory management concepts (virtual, real) to the operation of the vending machine. Relate processes and threads to the operation of the vending machine.
Directly address each question in your post. Your initial (first) post must be at least 150 - 200 words long.
In: Computer Science
In: Computer Science
What is a software process model? Explain. Describe completely any two generic software process models with relevant diagrams using any two different examples of software applications (one for each model).
2. Draw a state-machine model (diagram) for the control software for the camera on your mobile phone. You can ignore the flash component.
3. Draw a sequence diagram for a student to register for a course for the Spring 2021 semester. Check academic and financial holds, pre-requisites and ensure that the catalog of courses is available for the student to check the CRN and name of the course and section.
4. Which software attributes are most critical for the following systems? Explain your reasoning for each attribute in detail. a. Software used to control a robotic arm to fill in prescriptions at a large pharmacy. b. Application similar to Mercy Connect, which you can use to register for courses, apply for and check financial aid, review transcripts, etc.
5. Create a complete list of software requirements (user, system, functional, non-functional) for a typical Metro North or Amtrak Ticket Machine system. If you are not familiar with Metro North or Amtrak, pick any train station Ticket Machine in your city.
In: Computer Science