Questions
Introduction to Inheritance (Exercise 1) Write the class named Horse that contains data fields for the...

Introduction to Inheritance (Exercise 1)

Write the class named Horse that contains data fields for the name, color, and birth year. Include get and set methods for these fields. Next, finish the subclass named RaceHorse, which contains an additional field that holds the number of races in which the horse has competed and additional methods to get and set the new field.

Run the provided DemoHorses application that demonstrates using objects of each class.

DemoHorses.java

public class DemoHorses
{
public static void main(String args[])
{
Horse horse1 = new Horse();
RaceHorse horse2 = new RaceHorse();
horse1.setName("Old Paint");
horse1.setColor("brown");
horse1.setBirthYear(2009);
horse2.setName("Champion");
horse2.setColor("black");
horse2.setBirthYear(2011);
horse2.setRaces(4);
System.out.println(horse1.getName() + " is " +
horse1.getColor() + " and was born in " + horse1.getBirthYear() + ".");
System.out.println(horse2.getName() + " is " +
horse2.getColor() + " and was born in " + horse2.getBirthYear() + ".");
System.out.println(horse2.getName() + " has been in " + horse2.getRaces() + " races.");
}
}

Horse.java

public class Horse
{
// add private variables here

public String getName()
{
// write method code here
}
public String getColor()
{
// write method code here
}
public int getBirthYear()
{
// write method code here
}
public void setName(String n)
{
// write method code here
}
public void setColor(String c)
{
// write method code here
}
public void setBirthYear(int y)
{
// write method code here
}
}


RaceHorse.java

// Extend the Horse class as RaceHorse here
{
// add private variables here

public int getRaces()
{
// write method code here
}
public void setRaces(int r)
{
// write method code here
}
}

In: Computer Science

MIPS Program I'm trying to write a program that will take in two numbers from the...

MIPS Program

I'm trying to write a program that will take in two numbers from the user and output the sum at the end. However, I keep getting very wrong answers. For example, I add 2 and 2 and get 268501000. Help would be appreciated.

.data #starts data use
userIn1:
   .word 4 #sets aside space for input
  
userIn2:
   .word 4 #sets aside space for input
total:
   .word 4 #sets space aside for input
  
request:
   .asciiz "Enter an integer value: "

echoStr:
   .asciiz "The total is: "
  
.text #starts string use
.globl   main

  
main:
   #prints request for 1st number
   la $a0, request #loads string into argument
   li $v0, 4 #request to print set in register $v0
   syscall #execute
  
   #takes in user input
   la $a0, userIn1 #pointer to info
   li $v0, 5 #request for user input set in register $v0
   syscall
  
   #prints request for 2nd number
   la $a0, request #loads string into argument
   li $v0, 4 #request to print set in register $v0
   syscall #execute
  
   #takes in user input
   la $a1, userIn2 #pointer to info
   li $v0, 5 #request for user input set in register $v0
   syscall
  
   #NEXT CHUNK IS PROBABLY ISSUE
  
   #adds numbers together
   add $t0, $a0, $a1 #adds numbers together
   sw $t0, total #stores total
   syscall
  
  
   #prints out awknowledgement
   la $a0, echoStr #stores string in $a0 argument spot
   li $v0, 4 #request to print set in register $v0
   syscall
  
   #prints out user input
   la $a0, total #calls user input and stores it as argument 0
   li $v0, 1 #request to print set in register $v0
   syscall
  
   #to properly exit program
   li $v0, 10
   syscall

.data #end of data use

endl:   .asciiz   "\n"

In: Computer Science

You work for a large beverage distribution company and you are managing the "Milk or no...

You work for a large beverage distribution company and you are managing the "Milk or no Milk" project, which involves a redesign of the milk container for your company. You have several things to consider in order to complete the project successfully. Most generally, you will need to factor both the functional and nonfunctional requirements of the project. Complete a 750-1,000 word proposal that identifies the appropriate stakeholders, defines the requirements for the stakeholders, and states the rationale for the requirements. Also, identify the business requirements across the organization so that the data can be properly validated. Some of the functional requirements to consider are the business rules, industry rules, legal or regulatory requirements, and certification requirements. Some of the nonfunctional requirements to consider are performance (i.e., shelf life), reliability, environmental impact, and ease of use to open.

In: Computer Science

In C++ Complete the template program. ADD to your c++ program as a comment the PARTIAL...

In C++ Complete the template program.

ADD to your c++ program as a comment

the PARTIAL output from executing your

program - Only copy the last 6 lines of output.

There is no input data for this problem.

// Find Pythagorean triples using brute force computing.


#include <iostream>


using std::cout;


using std::endl;


int main()
{
int count = 0; // number of triples found


long int hypotenuseSquared; // hypotenuse squared


long int sidesSquared; // sum of squares of sides


cout << "Side 1\tSide 2\tSide3" << endl;


// side1 values range from 1 to 500


/* Write a for header for side1 */

{

// side2 values range from current side1 to 500


/* Write a for header for side2 */

{

// hypotenuse values range from current side2 to 500


/* Write a for header for hypotenuse */

{

// calculate square of hypotenuse value


/* Write a statement to calculate hypotenuseSquared */

// calculate sum of squares of sides


/* Write a statement to calculate the sum of the sides Squared */

// if (hypotenuse)^2 = (side1)^2 + (side2)^2,

// Pythagorean triple

if ( hypotenuseSquared == sidesSquared )

{

// display triple

cout << side1 << '\t' << side2 << '\t' << hypotenuse << '\n';

count++; // update count

} // end if
} // end for
} // end for
} // end for

// display total number of triples found

cout << "A total of " << count << " triples were found." << endl;

return 0; // indicate successful termination

} // end main

In: Computer Science

Qa: For fitness proportional, ranking and tournament selection separately, discuss a) convergence speed, is it problem-specific...

Qa: For fitness proportional, ranking and tournament selection separately, discuss
a) convergence speed, is it problem-specific or not?
b) can convergence speed be controlled and how?

Qb: What you possibly lose by increasing convergence speed?

In: Computer Science

Java. You are creating a 'virtual pet' program. The pet object will have a number of...

Java.

You are creating a 'virtual pet' program. The pet object will have a number of attributes, representing the state of the pet. You will need to create some entity to represent attributes in general, and you will also need to create some specific attributes. You will then create a generic pet class (or interface) which has these specific attributes. Finally you will make at least one subclass of the pet class which will be a specific type of pet, and at least one instance of that class.

Attributes
An attribute is a characteristic of a pet. Each attribute is essentially a list of values. For example, a hunger attribute may have values from "famished" through "content" to "bloated." There should be some way to check the value of the attribute, as well as to increase and decrease the value. Note that you will be expected to create some sort of abstract data type (ADT) to represent the attribute. You are not yet building SPECIFIC attributes (like hunger or happiness) but a type that represents the common characteristics of all attributes. You might use an interface or an abstract class to generate your abstraction, but plan it first as an abstract data type.

Specific Attributes
Once you have created a generic attribute class, make some subclasses to represent the specific attributes you want your pets to have. If you designed the ADT well, creating specific subclasses should be quite easy. The main method of the specific classes should test the main functionality of the class.

Making your abstract pet
Now create a pet class that uses the attributes you have generated. This class is also abstract, as it represents just a type of pet. It will include attributes as data members, and it may also have other characteristics. You may also add methods that indicate actions the user can take with the pet, including things like feed and play (which may affect attributes) and perhaps other activities like rename (which might change another data member of the pet) and sleep (which might indicate the passage of time.)

Build a specific pet class
Finally you should be able to build a specific type of pet (like a lizard or a unicorn) that inherits from the pet class. This should begin (of course) with characteristics derived from the abstract pet, but you could then add new attributes or behaviors specific to your type of pet.

The main method of this pet class should instantiate an instance of the pet and indicate all the things it can do.

Create an interface for interacting with the pet.
Build some type of tool for interacting with the pet. At minimum this should allow the user to create a pet, interact with it in the ways you have defined, save its current status for future play (using object serialization) and load a previously saved pet.

In: Computer Science

Write a function forward_eval that evaluates the interpolating polynomial using Newton’s Forward Difference table. The function...

Write a function forward_eval that evaluates the interpolating polynomial using Newton’s Forward Difference table. The function prototype and descriptive comments have been provided:

function y = forward_eval(X, T, x)

%FORWARD_EVAL Evaluate Newton's forward difference form of the

%interpolating polynomial

% y = FORWARD_EVAL(X, T, x) returns y = Pn(x), where Pn is the

% interpolating polynomial constructed using the abscissas X and % forward difference table T.

In: Computer Science

How would I add a quickSort function to the below C++ code to sort the randomly...

How would I add a quickSort function to the below C++ code to sort the randomly generated numbers?

#include <iostream>
#include <cstdlib>
#include <ctime>

using namespace std;
int i;
int array[10];
int odd;
int Max;
int counter = 0;

int main()

{
cout << "The 10 random elements are: ";
cout << endl;

srand ( time(0) );

for (int j = 0; j < 99; j++)
{
    i = rand() % 100;
    if (i != i - 1)
    array[j] = i;

else
{
    i = rand() % 100;
    array[j] = i;
}


}

for (int k = 0; k < 10 ; k++)
{
    cout << array[k] << "\n";

}

cout << endl;


return 0;
}

In: Computer Science

Try to make it as simple as you can and explain as much as it needed....

Try to make it as simple as you can and explain as much as it needed.

  1. Define Integrity and Nonrepudiation? (2 points)

Ans:

  1. What are the differences between Stream Cipher and Block Cipher? (2 points)

Ans:

  1. What is Access Control and why is it important? (2 points)

Ans:

  1. Message Authentication Code ensures authentication or integrity or both? Justify and explain your answer. (3 points)

Ans:

  1. What are the weaknesses of DES? Why triple DES is better than Double DES? (3 points)

Ans:

In: Computer Science

Write a C++ or Java application to create BOTH Stack & Queue data structures. The application...

Write a C++ or Java application to create BOTH Stack & Queue data structures.

The application also creates a "DisplayStackElement" and "DisplayQueueElement" routine. The application must be menu driven (with an option to terminate the application) and provide the following features.

Allow insertion of a "Circle" object/structure in the Stack data structures.

The Circle contains a "radius" data member.

The Circle also uses functions/methods "setRadius", "getRadius" and calculateArea (returns a double data type).

Allow insertion of a "Circle" object/structure in the Queue data structures.

Allow display of an element from Stack data structure by Invoking a method/function "DisplayStackElement" (uses the "Pop" method)

Allow display of elements from Queue data structure by Invoking a method/function "DisplayQueueElement" (uses "DeQueue" method).

Allow for deletion of the Stack Allow for deletion of the Queue

In: Computer Science

The Sum and The Average In C++, Write a program that reads in 10 integer numbers....

The Sum and The Average


In C++,

Write a program that reads in 10 integer numbers. Your program should do the following things:

Use a Do statement

Determine the number positive or negative

Count the numbers of positive numbers, and negative

Outputs the sum of:

all the numbers greater than zero

all the numbers less than zero (which will be a negative number or zero)

all the numbers

Calculate the average of all the numbers.


The user enters the ten numbers just once each and the user can enter them in any order. Your program should not ask the user to enter the positive numbers and the negative numbers separately

In: Computer Science

Try to make it as simple as you can and explain as much as it needed....

Try to make it as simple as you can and explain as much as it needed.

  1. Define Integrity and Nonrepudiation? (2 points)

Ans:

  1. What are the differences between Stream Cipher and Block Cipher? (2 points)

Ans:

  1. What is Access Control and why is it important? (2 points)

Ans:

  1. Message Authentication Code ensures authentication or integrity or both? Justify and explain your answer. (3 points)

Ans:

  1. What are the weaknesses of DES? Why triple DES is better than Double DES? (3 points)

Ans:

In: Computer Science

Try to make it as simple as you can and explain as much as it needed....

Try to make it as simple as you can and explain as much as it needed.

  1. What are the differences between symmetric encryption and asymmetric encryption? (1 point)

Ans:

  1. What is pseudo random numbers? (1 point)

Ans:

  1. What is Moore’s Law? (1 point)

Ans:

  1. What are four different block cipher modes? (1 point)

Ans:

  1. What is one-time pad? (1 point)

Ans:

In: Computer Science

package edu.depaul.triangle; import java.util.Scanner; /** * A class to classify a set of side lengths as...

package edu.depaul.triangle;

import java.util.Scanner;

/**

* A class to classify a set of side lengths as one of the 3 types

* of triangle: equilateral, isosceles, or scalene.

* If classification is not possible it emits an error message

*/

public class Triangle {

/**

* Define as private so that it is not a valid

* choice.

*/

private Triangle() {}

public Triangle(String[] args) {

//

// TODO: keep this simple. Constructors should not do a lot of work

//

}

// TODO: Add methods to validate input, and classify the triangle (if possible) here

private static String[] getArgs(Scanner s) {

System.out.println("press Enter by itself to quit");

System.out.println("enter 3 integers separated by space.");

String args = s.nextLine();

return args.split(" ");

}

public static void main(String[] a) {

try (Scanner scanner = new Scanner(System.in)) {

String[] args = getArgs(scanner);

// Loop until the user enters an empty line

while(args[0].length() !=0) {

//

// TODO: create a new Triangle here and call it

//

args = getArgs(scanner);

}

System.out.println("Done");

}

}

Write a Java program to determine types of triangles. The program reads 3 values from the standard input. The values represent the lengths of the sides of a triangle. The program prints a message to the standard output that indicates whether the triangle represented by the input is • an equilateral (all 3 sides are equal), or • an isosceles (exactly 2 of the 3 sides are equal), or • a scalene (all 3 sides are of different lengths) Expected behavior: a. The user enters 3 values at a prompt and presses return b. The values must be converted to integers. If they cannot be converted, the system displays an error. c. The valid values for these integers are values from 1 to and including 300. Any other integers should cause an error to be shown to the user. d. The values are delimited with spaces e. The system evaluates the results, shows either a triangle type or an error, then prompts for input again. f. When the user enters a blank line followed by return, the program ends. g. An error is shown whenever the user’s input cannot be interpreted as a triangle or when the handling of the input results in exception.

In: Computer Science

Write a C++ program to ask the user to enter the shape type: square, sphere or...

Write a C++ program to ask the user to enter the shape type: square, sphere or circle and the appropriate dimensions of the shape.. The program should output the following information about the shape:

a.for a square. it output the area and perimeter.

b. for a sphere, it outputs the area.

c. fir a circle, it outputs the volume.

if the user input anything else, your program should output: "the program does not recognize this shape". Use const whenever it is appropriate (use the nested if)

area of sphere is 4*PI*r^2

area of circle is Pi*r^2 (Pi=3.1416)

In: Computer Science