Questions
Java question: A rumor spreads in the following way: a person picks at random another person...

Java question: A rumor spreads in the following way: a person picks at random another person to inform of the rumor. If that person hasn't already been informed of the rumor, that person starts spreading the rumor as well. If that person had already been informed of the rumor, neither person spreads this rumor any further. Starting with 999 people who don't know the rumor and one who does and starts spreading it (1000 people in total), write a class in Java named RumorSpreading that simulates this situation and then prints the final percentage of the population that ends up knowing the rumor. Assume that we do NOT consider the case where more than one person spreads the rumor simultaneously.

In: Computer Science

a. what is digital code b. explain why different types of codes are used to encode...

a. what is digital code

b. explain why different types of codes are used to encode and decode data

c. discuss the reasons why hybrid codecs might be chosen over source codecs in voice over internet protocol communications

In: Computer Science

Hi, Java Question and thanks in advance. // TODO once BoundingBox and Draw are implemented, change...

Hi, Java Question and thanks in advance.

// TODO once BoundingBox and Draw are implemented, change Fixtures.simpleCircle
// to Fixtures.complexGroup and test the app on an emulator or Android device


@Override
@SuppressLint("DrawAllocation")
protected void onDraw(final Canvas canvas) {
   final Shape shape = Fixtures.simpleCircle;
   final Location b = shape.accept(new BoundingBox());
   canvas.translate(-b.getX(), -b.getY());
   b.accept(new Draw(canvas, paint));
   shape.accept(new Draw(canvas, paint));
   canvas.translate(b.getX(), b.getY());
}
public class BoundingBox implements Visitor {

   // TODO entirely your job (except onCircle)

   @Override
   public Location onCircle(final Circle c) {
      final int radius = c.getRadius();
      return new Location(-radius, -radius, new Rectangle(2 * radius, 2 * radius));
   }

   @Override
   public Location onFill(final Fill f) {
      return null;
   }

   @Override
   public Location onGroup(final Group g) {

      return null;
   }

   @Override
   public Location onLocation(final Location l) {

      return null;
   }

   @Override
   public Location onRectangle(final Rectangle r) {
      return null;
   }

   @Override
   public Location onStrokeColor(final StrokeColor c) {
      return null;
   }

   @Override
   public Location onOutline(final Outline o) {
      return null;
   }

   @Override
   public Location onPolygon(final Polygon s) {
      return null;
   }
}
mport android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Paint.Style;
import edu.luc.etl.cs313.android.shapes.model.*;

/**
 * A Visitor for drawing a shape to an Android canvas.
 */
public class Draw implements Visitor {

   // TODO entirely your job (except onCircle)

   private final Canvas canvas;

   private final Paint paint;

   public Draw(final Canvas canvas, final Paint paint) {
      this.canvas = null; // FIXME
      this.paint = null; // FIXME
      paint.setStyle(Style.STROKE);
   }

   @Override
   public Void onCircle(final Circle c) {
      canvas.drawCircle(0, 0, c.getRadius(), paint);
      return null;
   }

   @Override
   public Void onStrokeColor(final StrokeColor c) {

      return null;
   }

   @Override
   public Void onFill(final Fill f) {

      return null;
   }

   @Override
   public Void onGroup(final Group g) {

      return null;
   }

   @Override
   public Void onLocation(final Location l) {

      return null;
   }

   @Override
   public Void onRectangle(final Rectangle r) {

      return null;
   }

   @Override
   public Void onOutline(Outline o) {

      return null;
   }

   @Override
   public Void onPolygon(final Polygon s) {

      final float[] pts = null;

      canvas.drawLines(pts, paint);
      return null;
   }
}
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Paint.Style;
import edu.luc.etl.cs313.android.shapes.model.*;
import java.util.*;

/**
 * A Visitor for drawing a shape to an Android canvas.
 */
public class Draw implements Visitor<Void> {

   // TODO entirely your job (except onCircle)

   private final Canvas canvas;

   private final Paint paint;

   public Draw(final Canvas canvas, final Paint paint) {
      this.canvas = canvas; // FIXED
      this.paint = paint; // FIXED
      paint.setStyle(Style.STROKE);
   }

   @Override
   public Void onCircle(final Circle c) {
      canvas.drawCircle(0, 0, c.getRadius(), paint);
      return null;
   }

   @Override
   public Void onStrokeColor(final StrokeColor c) {
      final int x = paint.getColor();
      paint.setColor(c.getColor());
      c.getShape().accept(this);
      paint.setColor(x);
      return null;
   }

   @Override
   public Void onFill(final Fill f) {
      final Style a = paint.getStyle();
      paint.setStyle(Style.FILL_AND_STROKE);
      f.getShape().accept(this);
      paint.setStyle(a);
      return null;
   }

   @Override
   public Void onGroup(final Group g) {
      final Iterator<? extends Shape > shape = g.getShapes().iterator();
      while (shape.hasNext()) {
         shape.next().accept(this);
      }
      return null;
   }

   @Override
   public Void onLocation(final Location l) {
      canvas.translate(l.getX(), l.getY());
      l.getShape().accept(this);
      canvas.translate(-l.getX(), -l.getY());
      return null;
   }

   @Override
   public Void onRectangle(final Rectangle r) {
      canvas.drawRect(0, 0, r.getWidth(), r.getHeight(), paint);
      return null;
   }

   @Override
   public Void onOutline(Outline o) {
      final Style before = paint.getStyle();
      paint.setStyle(Style.STROKE);
      o.getShape().accept(this);
      paint.setStyle(before);
      return null;
   }

   @Override
   public Void onPolygon(final Polygon s) {
      List<? extends Point> points = s.getPoints();
      final float[] pts =
            {
                  points.get(0).getX(), points.get(0).getY(),
                  points.get(1).getX(), points.get(1).getY(),
                  points.get(1).getX(), points.get(1).getY(),
                  points.get(2).getX(), points.get(2).getY(),
                  points.get(2).getX(), points.get(2).getY(),
                  points.get(3).getX(), points.get(3).getY(),
                  points.get(0).getX(), points.get(0).getY(),
            };
      canvas.drawLines(pts, paint);
      return null;
   }
}
* A shape visitor for calculating the bounding box, that is, the smallest
 * rectangle containing the shape. The resulting bounding box is returned as a
 * rectangle at a specific location.
 */
public class BoundingBox implements Visitor<Location> {

   // TODO entirely your job (except onCircle)

   @Override
   public Location onCircle(final Circle c) {
      final int radius = c.getRadius();
      return new Location(-radius, -radius, new Rectangle(2 * radius, 2 * radius));
   }

   @Override
   public Location onFill(final Fill f) {
      return null;
   }

   @Override
   public Location onGroup(final Group g) {

      return null;
   }

   @Override
   public Location onLocation(final Location l) {

      return null;
   }

   @Override
   public Location onRectangle(final Rectangle r) {
      return null;
   }

   @Override
   public Location onStrokeColor(final StrokeColor c) {
      return null;
   }

   @Override
   public Location onOutline(final Outline o) {
      return null;
   }

   @Override
   public Location onPolygon(final Polygon s) {
      return null;
   }
}

In: Computer Science

I need a couple sentences about Creating and testing JavaScript.

I need a couple sentences about Creating and testing JavaScript.

In: Computer Science

Please, how to construct a class template in Python? Class name is animal: give it a...

Please, how to construct a class template in Python?

Class name is animal:

give it a set of class variables called: gender, status

give it a set of class private variables: __heart, __lungs, __brain_size

construct methods to write and read the private class variables

in addition initiate in the constructor the following instance variables: name, location as well as initiate the variables status and gender all from constructor parameters

The variables meaning is as follows:

name is name

status is wild or domestic

location is location

gender is gender (M/F)

Private variables have all values Yes or NO only __brain_size should be a number

Be sure to provide a check on every variable that requires it.. Yes/No variables can only get values Yes/NO, Numeric variables only number. The rest does not need a check.

Finally provide a method that will print the class state on the output such as

Animal Name: Name

Animal Location: location

etc (print all parameters with the appropriate description)

All variables that you are initializing will depend on the user

In: Computer Science

You are implementing a brand new type of ATM that provides exact amounts of cash (bills...

You are implementing a brand new type of ATM that provides exact amounts of cash (bills only, no coins). In order to maximize potential revenue an algorithm is needed that will allow for using different denomination amounts as needed by the local currency (value of bills will vary, but are integers).

  1. The program shall graphically prompt the user for a file.

  2. The program shall read the selected file of which the first line will be a space separated list of the

    bill denomination sizes.

  3. The program shall then read each line in the rest of the file containing an integer and output the

    number of different ways to produce that value using the denominations listed in the first line.

  4. The program shall indicate after that the number of milliseconds the program spent calculating

    the answer.

  5. The program shall implement 2 different forms of the algorithm: 1 recursive and 1 using dynamic

    programming.

  6. The program shall have 2 sets of output, 1 for each implementation.

  7. The program shall write the output to a file in the same directory as the input file.

  8. The program must be written in Java.

In: Computer Science

In C++ ifdef QUESTION2    /*    2. Create a header and implementation for a class...

In C++

ifdef QUESTION2
   /*
   2. Create a header and implementation for a class named bottle. bottle objects should be able
   to set and get their size in ounces, the type of liquid it contains(as a string), the amount of
   liquid it contains and whether they are less than another bottle object(based on the amount
   of liquid they contain). Do not comment your code.
   */

   std::cout << "QUESTION 2: " << std::endl << std::endl;

   std::cout << std::boolalpha;

   bottle myBottle;
   bottle anotherBottle;

   myBottle.setLiquidType("water");
   myBottle.setSize(32.0);
   myBottle.setFillAmount(20.0);

   anotherBottle.setLiquidType(myBottle.getLiquidType());
   anotherBottle.setSize(myBottle.getSize());
   anotherBottle.setFillAmount(10.0);

   std::cout << "myBottle is less than anotherBottle: " << myBottle.isLessThan(anotherBottle) << std::endl;

   std::cout << std::endl << std::endl;

#endif

In: Computer Science

Are the existing laws and regulations sufficient to accommodate cloud computing towards the edge or ‘edge...

Are the existing laws and regulations sufficient to accommodate cloud computing towards the edge or ‘edge cloud’ or ‘edge cloud computing’ if so could you outline and or explain some of them Whatever your answer is please provide evidence as to why there needs to be a change or not maybe links to some articles or references to books where i can read more about it

In: Computer Science

In this case study, your task is to study different search algorithms to solve the N-Queens...

In this case study, your task is to study different search algorithms to solve the N-Queens Problem which has been presented in class. We will focus on the incremental formulation in which we add a queen to any square in the leftmost empty column that is not attacked by any other queen.

Question: Using Depth-first Search (DFS) algorithms, how many steps are needed to find the solution for the 8-Queens Problem? What is it? Draw on an 8x8 table. Show your steps.

In: Computer Science

Apart from the formal parameter(s) and the body of the function, what else does the closure...

Apart from the formal parameter(s) and the body of the function, what else does the closure
ADT encapsulate? Why is this necessary for correct evaluation of the function at call-time?
Give a concrete example if possible

In: Computer Science

C++ Code While Loops. Ask user for file and open file. Do priming read and make...

C++ Code While Loops.

Ask user for file and open file.

Do priming read and make a while loop that: 1. Reads in numbers. 2. Counts how many there is. 3. Also for every 10 numbers in the file, print out the average of those 10 numbers. Ex: (If 20 numbers in the file. "With 10 numbers the average is .... and With 20 numbers the average is" and EX for a file with 5 numbers "There are 5 numbers in this file with an average of ..."

After the loop calculate and print the average of all nums in the file.

In: Computer Science

In this case study, your task is to study different search algorithms to solve the N-Queens...

In this case study, your task is to study different search algorithms to solve the N-Queens Problem which has been presented in class. We will focus on the incremental formulation in which we add a queen to any square in the leftmost empty column that is not attacked by any other queen.

Question: Using Hill Climbing (HC) algorithms, how many steps are needed to find the solution for the 12-Queens Problem? What is it? Draw on an 12x12 table. Show your steps.

In: Computer Science

Create a class Superheros member: Map heroMap //key = name, value = weapon (or get creative)...

Create a class Superheros

member: Map heroMap //key = name, value = weapon (or get creative)

member: Set< String> powerSet //superpowers

*** initialize your map & set – preferably in constructor ***

/* One liner to ‘put’ the key, value pair you’re passing in.. */

Method: void putEntryInMap (String key, String value) {}

/* Another 1 liner – well maybe 2. (1) ‘get’ the value from the map with the key (2) capture that value and return it (to your testHarness) */

Method: String getEntryFromMap (String key) {}

/* Another 1/2 liner (1) ‘remove’ the value from the map with the key (2) check if you have actually removed your value from your map by printing the results of heroMap.hasKey(key) */

Method: void removeEntryFromMap (String key){}

/* For all the marbles… you need to: Get the keyset from your map. This will give you a set of all the keys in the map. With your keyset, iterate over each element in your set & in the loop ‘get’ the value for that key from your map & print it. (Note you will need to create a local Set variable in this method). */

Method void displayAllMapEntries(){}

/* add an element to your set */

Method void addToSet(String name){}

/* remove an element from your set */

Method void removeFromSet(String name){}

/* iterate over the elements in your set and print each */

Method void printSet(){}

In your testHarness:

- create a Superhero instance ( make sure your map & set are initialized in your Superhero ctor ) - invoke one of your Superhero methods to ‘put’ a few entries ( 4 or more ) in your map.

- invoke one of your Superhero methods to ‘display’ your cat entries - invoke one of your Superhero methods ‘get’ an entry

- capture the value returned in your harness & print it out. - invoke one of your Superhero methods ‘remove’ an entry - invoke one of your Superhero methods to ‘display’ each entry (do not just print the map)

- invoke one of your Superhero methods to ‘add’ a few entries into your set

Make sure you add a couple duplicate names!

- invoke one of your Superhero methods to ‘display’ your set (do not just print the set) - invoke one of your Superhero methods to ‘remove’ an entry from your set - invoke one of your Superhero methods to ‘display’ your updated set (do not just print the set)

In: Computer Science

JAVA question here, and thank you. I need ot update the following classes an fixme's on...

JAVA question here, and thank you. I need ot update the following classes an fixme's on this.canvas = null etc.

Thanks!

import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Paint.Style;
import edu.luc.etl.cs313.android.shapes.model.*;

/**
 * A Visitor for drawing a shape to an Android canvas.
 */
public class Draw implements Visitor<Void> {

   // TODO entirely your job (except onCircle)

   private final Canvas canvas;

   private final Paint paint;

   public Draw(final Canvas canvas, final Paint paint) {
      this.canvas = null; // FIXME
      this.paint = null; // FIXME
      paint.setStyle(Style.STROKE);
   }

   @Override
   public Void onCircle(final Circle c) {
      canvas.drawCircle(0, 0, c.getRadius(), paint);
      return null;
   }

   @Override
   public Void onStrokeColor(final StrokeColor c) {

      return null;
   }

   @Override
   public Void onFill(final Fill f) {

      return null;
   }

   @Override
   public Void onGroup(final Group g) {

      return null;
   }

   @Override
   public Void onLocation(final Location l) {

      return null;
   }

   @Override
   public Void onRectangle(final Rectangle r) {

      return null;
   }

   @Override
   public Void onOutline(Outline o) {

      return null;
   }

   @Override
   public Void onPolygon(final Polygon s) {

      final float[] pts = null;

      canvas.drawLines(pts, paint);
      return null;
   }
}

In: Computer Science

As a Sys admin you were asked to plan a network including three subnets each one...

As a Sys admin you were asked to plan a network including three subnets each one for a different usage. You may plan the net for the organization you are familiar with, or an imaginary net you dreamed to implement. Be specific with your plan including all IP Addresses hosts. Include a graphic layout of your plan.

In: Computer Science