Number of bits in the given message (size of m) |
|
No of parity bits required as per Hamming’s algorithm (size of r) |
|
The final message that is transferred along with parity bits (Final Answer) |
In: Computer Science
Language C++
Student-Report Card Generator:
create a class called student and class called course.
student class
this class should contain the following private data types:
- name (string)
- id number (string)
- email (s)
- phone number (string)
- number of courses (int)
- a dynamic array of course objects. the user will specify how many courses are there in the array.
the following are public members of the student class:
- default constructor (in this constructor, prompt the use enter values for all the private data members of student class)
- argument constructor
- display method to display the student information in a proper and acceptable format.make sure to overload the insertion operator for this purpose.
course class:
this class should contain the following private data types:
- course code (string)
- course title (string)
- course grade (double)
- course credits (int)
the following are public members of the course class:
- default constructor (in this constructor, prompt the use enter values for all the private data members of course class) [show me how you will manage this situation]
- argument constructor
- average method to calculate and return the average of the student grades.
- display method to display the grades in a proper and acceptable format.make sure to overload the insertion operator for this purpose.
Testing:
test your classes by creating 2 objects of student, one using the default constructor and the other one using the argument constructor. make sure to display the data of each object.
In: Computer Science
In: Computer Science
In: Computer Science
Write a PHP script that:
1) Has an associative array with 10 student names and test scores (0 to 100). ie. $test_scores('John' => 95, ... );
2)Write a function to find the Average of an array. Input is an array, output is the average. Test to make sure an array is inputted. Use ARRAY_SUM and COUNT.
3)Output the test scores highest to lowest, print scores above the average in Green. Find a PHP Sort function for associative arrays, high to low. <font color='green'>text</font>
4)Output the test scores lowest to highest, print scores below the average in Red. Find a PHP Sort function for associative arrays, low to high. <font color='red'>text</font>
In: Computer Science
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 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 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 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 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 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 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 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.
Ans:
Ans:
Ans:
Ans:
Ans:
In: Computer Science
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