You are to implement a string compression algorithm with the following specifications:
Create a function RLE() to implement this algorithm recursively, this function should take in a string message and return the compressed string as an output.
Python code
In: Computer Science
All in MIPS assembly
1. Have the user input a 32 bit binary string
2. convert that into decimal
3. Print the decimal
In: Computer Science
Identifying OSI Model Layers from Captured Packets Time Required: 15 minutes Objective: Use Wireshark to capture the packets generated from an HTTP communication session. Identify the OSI model layers represented by the headers in the captured files. Required Tools and Equipment: Net-XX with Wireshark installed and Internet access
Description: Using Wireshark and an appropriate capture filter, capture the packets involved in an HTTP session that you start by opening a Web page. Select an HTTP packet, and using the headers in the middle pane, perform the following tasks:
In: Computer Science
Write a program which alternately prints "Hello, world!" and "Buy Coca-Cola!" for fixed intervals, between screen clears, indefinitely. The "Buy Coca-Cola" message should be below the liminal threshold (the user not be able to consciously perceive it), which is about 200ms. Call this blink.cpp. must be in c++
In: Computer Science
Programming
Write a program that initializes an array with 10 random integers between 0 and 100 and then prints exactly 5 lines of output. These 5 lines should contain:
Initially write your code so that you initialize the array in the main method. You will not ask the user for any input, but will use Math.random to generate 10 random numbers between 0 and 100 to put in the array.
As an example, if the array contained { 34, 82, 45, 92, 71, 1, 18, 20, 52, 99 }, the five lines would be:
Array: [ 34, 82, 45, 92, 71, 1, 18, 20, 52, 99 ]
Elements at even index: 34 45 71 18 52
Even elements: 34 82 92 18 20 52
Reverse order: 99 52 20 18 1 71 92 45 82 34
First: 34 and Last: 99
If you complete all the steps above, please go back and move your code that fills the array into a separate method within your class. The method will create the array, fill it with the random numbers, and then return it to the caller.
Remember to use good coding style, and javadoc comments where appropriate.
NOTE: Please read instruction and example carefully while writing java code. Please include JAVADOC too. Thank you in advance.
In: Computer Science
Write a test program that prompts the user to enter 10 numbers and displays the mean and deviation, as shown in the following sample run:
Your program should contain the following functions:
// Compute the mean of an array of double values double mean(const double x[], int size) // Compute the deviation of double values double deviation(const double x[], int size)
Write a test program that prompts the user to enter 10 numbers and displays the mean and deviation, as shown in the following sample run:
ex:
Enter ten numbers: 1.9 2.5 3.7 2 1 6 3 4 5 2
The mean is 3.11
The standard deviation is 1.55738
So this what I have:
#include <iostream>
#include <cmath>
using namespace std;
void displayVals(int vals[], int numVals, int sum);
void getVals(int vals[], int numVals);
double average(int sum, int numVals);
double stanDev(int vals[], double mean, int numVals);
int main()
{
int numVals=10;
int sum = 0;
int vals[9];
getVals(vals, numVals);
cout << endl;
displayVals(vals, numVals, sum);
cout << endl;
}
void getVals(int vals[], int numVals)
{
int index;
cout << "Enter ten numbers :" <<
"\n";
for (index = 0; index < numVals; index++) {
cout << index + 1;
cin >> vals[index];
}
}
void displayVals(int vals[], int numVals, int sum)
{
int index;
for (index = 0; index < numVals; index++) {
cout << index + 1;
cout << vals[index] <<
".\n";
}
cout << endl;
cout << "The mean is ";
cout << average(vals, numVals, sum) <<
".\n";
cout << endl;
cout << "The standard deviation is: ";
cout << stanDev(vals, numVals, sum) <<
".\n";
}
double average(int sum, int numVals)
{
double dsum = (double)sum;
double dnumVals = (double)numVals;
return dsum / dnumVals;
}
double stanDev(int vals[], double mean, int numVals)
{
double sum = 0, dVals = 0, value = 0, variance =
0;
for (int i = 0; i < numVals; i++)
{
dVals = (double)vals[i];
value = (dVals - mean)*(dVals -
mean);
sum += value;
variance = sum / (numVals);
}
return sqrt(variance);
}
In: Computer Science
1. Why librarians need to be familiar with online
databases
2. What is online database?
3. overview of those two databases (jstor and project MUSE)
4. List of journals under their domains
5. Functionalities of each database
6. Layout and
structural usability of each database
Comparison between those two databases (if any)
In: Computer Science
I WANT THIS CODE TO BE SIMPLE BECAUSE I AM NEW TO CODING AND I WANT TO KNOW THE DETAILS! straight C
Write a quiz program that helps a student learn the multiplication operation. A series of questions are asked, such as: What is 12 mod 5?Note: the numbers 12 and 5 were randomly generated by your program. After the user types in their answer, print a suitable message to the screen. The game ends after 4 wrong answers.
In: Computer Science
Develop the 8-point Discrete Fourier Transform (DFT) using butterfly diagrams for the discrete input sequence x(n) = {1, 2, 3, 4, 4, 3, 2, 1} using radix-2 Decimation in Frequency - Fast Fourier Transform (DIF-FFT) algorithm.
In: Computer Science
Can someone add comments on this explaining the code and also I could not figure out how to code the finalbattle to make it where if u use a lowercase "a" for the final attack you lose.
from sys import exit
print ("The city needs your help, you must save them!")
print ("What is your name?")
name=input("Enter your name:")
print ("Ok, are you ready to begin?")
def decisions():
decision = input("yes or no?\n")
if decision == "yes":
print ("You made the right decision, may your blade keep you
safe.")
elif decision == "no":
print ("You have let the people down and the city will be
destroyed.")
exit(0)
decisions()
def choosepath():
print ("You must leave the town in order to save the
people.")
print ("You may go either north or south to destroy the enemies
raiding the city.")
print ("The paths to the east and west have been destroyed and it
is up to you to stop this from happening elsewhere.")
path = ''
while path !='north' and path !='south'and path !='east' and path
!='west':
print ("which path would you like to take?")
print ("choose north or south:")
path = input()
if path =="north":
print ("You head north towards the enemy approching the front
gates.")
elif path=="south":
print ("You head south to sneak up on the enemy and attack from
behind.")
choosepath()
print("You arrive at the battle and start planning your
attack!")
print("You spot an enemy and must make a wise decision to start
your fight...")
print("Before picking your target you must choose your
weapon!")
def weapon():
weapon = ''
while weapon != 'sword' and weapon !='axe':
print("Choose your sword or axe!")
weapon = input ()
if weapon == "sword":
print("You chose sword!")
elif weapon =="axe":
print ("You chose axe!")
weapon()
print("Now that you have chosen your weapon it is time to
attack!")
print("You look around for a brief moment...")
print("You start to have doubts, now is your chance to turn
around.")
print("Would you like to turn around and let the people die to save
your own life?")
final_decision = input ("yes or no?\n")
if final_decision == "yes":
print("You have let the people down...")
exit(0)
elif final_decision =="no":
print("You are a brave knight.")
print("Now is your time to strike!")
print("Quickly! the enemy is approaching, it is now or never!")
enemy = 0
a=50
A=50
enemy_approaches = input ("Press a to attack!")
if enemy_approaches=='a' or enemy_approaches =='A':
enemy = enemy + 50
enemy_approaches = input ("The enemy is getting weaker keep
attacking!")
if enemy_approaches=='a' or enemy_approaches =='A':
enemy = enemy + 50
enemy_approaches = input ("Time for the final blow!")
if enemy_approaches=='a' or enemy_approaches =='A':
enemy = enemy+ 50
if enemy >= 150:
print ("Congratulations, you have defeated the enemy!")
def finalbattle():
print("You defeated a soldier now it is time to take out the
leader!")
print("You must be careful great knight, he if very
powerful!")
print("You will need to use power attacks to defeat him!")
print("Use capital A for a power attack.")
print("Use basic attacks until he is stunned, when the time is
right kill him with a powerful blow!")
print("...")
print("NOW! IT IS TIME TO ATTACK!")
finalbattle()
enemy = 0
a=50
A=100
enemy_approaches = input ("Press a to attack!")
if enemy_approaches=='a':
enemy = enemy + 50
enemy_approaches = input ("One more and you will have him
stunned!")
if enemy_approaches=='a':
enemy = enemy + 50
enemy_approaches = input ("You stunned him! Use your powerful
strike")
if enemy_approaches =='A':
enemy = enemy+ 100
if enemy >= 200:
print("You have defeated the boss and saved the city!")
print("YOU WIN!")
In: Computer Science
hi guys, could someone tell my where this is going wrong please, its adding into a double linked list, i have another method to add at the end which is working but the rest of this??
thanks
public boolean add(int index, Token obj) {
if(obj == null) {
throw new
NullPointerException();
}
if (index < 0 || index >
this.size()-1) {
throw new
IndexOutOfBoundsException();
}
// new node to add
Node toADD = new
Node(null,null,obj);
//insert at the beginning of the
list
if(index == 0) {
// make the next
of the new node point to the previous head, and previous to
null
toADD.next =
head;
toADD.prev =
null;
//change the
previous of head to the new node
if(head != null)
{
head.prev = toADD;
// set the new
node to be the head;
head =
toADD;
size++;
}
if(index >1) {
for(int i =1;
i<= index; i++ ) {
if(index == i) {
Node oldNode =
this.getNode(i);
toADD.prev =
oldNode.prev;
oldNode.prev = toADD;
toADD.next = oldNode;
toADD.prev.next =
oldNode;
size++;
}
if(index == this.size()-1) {
this.add(obj);
In: Computer Science
4. Read three recent news articles about Biometrics and write a brief summary. Include a reference to each article.
In: Computer Science
In Java Language.
Must Include Comments.
We will simulate a dice game in which 2 dice are rolled.
If the roll is 7 or 11, you win.
If the roll is 2, 3 or 12, you lose
If the roll is any other value, it establishes a point.
If, with a point established, that point is rolled again before a 7, you win.
If, with a point established, a 7 is rolled before the point is rolled again you lose.
Build your algorithm incrementally. First write a program that simulates a roll of two dice, then
outputs if it is a simple win (7 or 11), or a simple loss (2 or 3 or 12), or something else.
1. I will help you with the algorithm:
//get a random number between 1 and 6, call it d1
//get a second random number between 1 and 6, call it d2.
//compute the total & print it so we know what it was
//if the total is 7 or 11 print “congratulations, you win”
// else if the total is 2 or 3 or 12 print “you lose”
//else print “something else”
2. Create the program and test it by running it a few times to verify that you are correctly
printing whether you won, lost, or “something else”.
3. Now fix the part where you wrote “something else”. In this case you rolled a number which
we called total. We need to keep rolling the dice and looking at the new total each time. If the
new total is the same as total, you win. If the new total is 7, you lose. And if something else
you roll again...... For example, an initial total of 6 was neither a win or a lose. So 6 is now
the important number called “point” above. Roll the dice again, if it is 6 you win, and if 7 you
lose. If anything else you roll again and keep doing so until you roll either a 6 and win, or 7
and lose.
Write this part of your algorithm here (or on another piece of paper). Once we verify your logic is
correct you may code it.
In: Computer Science
Cyber Security Control Frameworks are created to provide guidance in developing security policies and procedures. State the control frameworks and give two examples of how this control is applicable in developing security policies and procedures?
In: Computer Science
Using Visual Studio, C# Programming
Lecture: Objects, Inheritance and abstract classes, member init list, shape, circle and cylinder.
Complete Exercises 4 and 5 (100pts)
4. Person and customer classes
Design a class named Person with properties for holding a person's name, address, and telephone number. Next, design a class named Customer, which is derived form the Person class. The Customer class should have a property for a customer number and a Boolean property indicating whether the customer wishes to be on a mailing list, Demonstrate an object of the Customer class in a simple application.
5. PreferredCustomer Class
A retail store has a preferred customer plan where customers can earn discounts on all their purchases. The amount of a customers discount is determined by the amount of the customers cummulative purchases in the store as follows:
- When a preferred customer spends $500, he or she gets a 5 percent discount on all future purchases.
- When a preferred customer spends $1,000, he or she gets a 6 percent discount on all future purchases.
- When a preferred customer spends $1,500, he or she gets a 7 percent discount on all future purchases.
- When a preferred customer spends $2,000, he or she gets a 10 percent discount on all future purchases.
Design a class named PreferredCustomer, which is derived from the Customer class you created in Exercise 4. The PreferredCustomer class should have properties for the amount of the customer's purchases and the customer's discount level. Demonstrate the class in a simple application.
Complete below for 100pts extra credit
Person[] people=new Person[2];
people[0]=new Customer(arguments here);
people[1]=new Preferredcustomer(arguments here);
people[0].calcdiscount();
people[1].calcdiscount();
| use overridden methods to effect polymorphism. | overload operators
to enable them to manipulate objects. |
| determine an
object’s type at execution time. |
create sealed
methods and classes. |
| create abstract
classes and methods. |
In: Computer Science