1) Suppose we have the following IP addresses for two different organizations, we have to create 5 networks having 30 hosts in it. Find first sub network ID, Fist address, Last address and Broadcast for each of the following given addresses?
a) 14.23.120.8
b) 252.5.15.111
In: Computer Science
Utilizing PHP and HTML code
Create a form that has text inputs for two numbers and a submit button. Submit the values to a program that calculates and displays the GCD of the two numbers. The greatest common divisor of two integers a and b is the largest integer that is a factor of both a and b.
The GCD of any number and 1 is 1, and the GCD of any number and 0 is that number.
For example:
gcd(24, 84) =12,
gcd(105, 45) =15,
gcd(409, 1) = 1,
and gcd(0, 8) =8.
You could set up a loop for each number and find all the factors using the modulo operator. Then you could compare the two lists of factors and find the largest number they have in common. This would work but it is going to be slow for very large numbers.
One efficient way to compute the GCD is to use Euclid's Algorithm, which states the following:
gcd(a, b) = gcd(b, a % b)
gcd(a, 0) = Absolute value of a
Here is an example of using this algorithm for 154,320 and 4,320
Looks like it would be perfect for a while loop.
In: Computer Science
I need to make pseudo code for hybrid priority
queue using both minheap and maxheap by ARRAY.
i need to have a function that extends the size of array once it
meets certain condition.
Also, I need to implement function remove, insert(k,v), top,
toggle, switchtoMin, switchtoMax, state, isEmpty, and size.
Please guide me the pseudo code with above conditions
In: Computer Science
This is for c++
Write a program that works with two arrays of the same size that are related to each other in some way (or parallel arrays). Your two arrays must be of different data types.
For example, one array can hold values that are used in a formula that produces the contents of the second array. Some examples might be:
from a previous program, populations and the associated flowrates for those populations (an int array of populations and a double array of the associated flowrate)
a series of values and the square roots of those integers (an int array of values and a double array of associated square roots)
a series of values and an indication of whether or not each value is odd or even (an int array and a bool array)
1. Declare and initialize a constant to represent the size of both arrays (at least 10 positions)
2. Declare and initialize your first array
3. Declare and initialize your second array, based on the data in your first array
4. Output the contents of both arrays in neat columns with headers
Optional suggestions (good to do, not required)
1. Try to break your program up into different functions
2. Use user input to initialize the first array
In: Computer Science
Write an MPI program that implements the hypercube bitonic sort algorithm. The program should be tested using a sequence of 64 integers (from 1 to 64, initially not sorted) and 8 processes. The number of elements assigned to each process is 8.
In: Computer Science
In: Computer Science
Please write in java: Write a fragment that reads a sequence of strings and inserts each string that is not numeric at the front of a deque and each string that is numeric at the rear of a deque. Your fragment should also count the number of strings of each kind. Display the message "Strings that are not numeric" followed by the nonnumeric strings and then the message "Strings that are numbers" followed by the numeric strings. Do not empty the deque.
In: Computer Science
In: Computer Science
using recursion no loops allowed(for,while..ect) not allowed #4: Write a recursive function ‘bool palindrome(string s)’ that returns true if s is a palindrome and false if not. #5: Write a recursive function 'void reverse(string &word)' that reverses the given input string. string name = "damian"; reverse(name); cout << name << endl; //should display "naimad". #6: Write a function 'string binary(int n)' that returns a string of 1's and 0's which is the binary representation of n. cout << binary(43) << endl; // 101011 #7: Write a function 'int numTwos(int n)' which returns the number of 2's in the base-4 expansion of n. cout << numTwos(2170) << endl; // 3
c++
In: Computer Science
Java Programming (8th Edition) Joyce Farrell p.530, Chapter 10 Problem 1E with user input with scanner and the following results:
Enter name of horse: ABC
Enter color of horse: Red
Enter year: 2000
Enter name of horse: DEF
Enter color of horse: Blue
Enter year: 2010
Enter number of races: 6
ABC is red and born in 2000.
DEF is blue and born in 2010.
DEF completed 6 races..
In: Computer Science
This week’s journal articles focus on empowering leadership and effective collaboration in geographically dispersed teams, please answer the following questions:
How do geographically dispersed teams collaborate effectively?
Please find at least three tools on the market that teams can use to collaborate on a geographically dispersed team. Please note the pros and cons of each tool.
In: Computer Science
Suppose you need to transfer some data ensuring integrity and authentication and confidentiality of data. Explain the steps.
Please don't provide handwritten solution for this question.
In: Computer Science
You are working as a Security Engineer in ABX Company Pvt. Ltd. Suddenly, intruder has got access to their database and used them to impersonate users to get some documents. Fortunately, attack was identified and the stopped by your team. Now, your manager asked you to find a secure way to store password securely and others could not able to reverse it or use it for login. What will be your solution? Would you use hashing? If you use hashing please explain the steps.
In: Computer Science
Please write in java: Write a recursive method toNumber that forms the integer sum of all digit characters in a string. For example, the result of toNumber("3ac4") would be 7. Hint: If next is a digit character ('0' through '9'), Character.isDigit(next) is true and the numeric value of next is Character. digit(next, 10).
In: Computer Science
**********************************java**********************************************************
Purpose: The purpose for this project is to reinforce the knowledge from Chapter 9 of the textbook. The students will learn how to write a user defined class.
Project Objectives:
Apply UML design on user defined class
Write overloaded constructors of a class
Write mutators (i.e. get methods) and accessors (i.e. set methods) of a class
Write overloaded methods
Write main method to test the user defined class
Class Diagram:
Student must implement the Temperature class according to the following class design.
Temperature
-‐degree: double
-‐scale: char
+Temperature()
+Temperature(degree: double)
+Temperature(scale: char)
+Temperature(degree: double, scale: char)
+getDegreeInCelsius(): double
+getDegreeInFahrenheit(): double
+setDegree(degree: double): void
+setDegree(scale: char): void
+setDegree(degree: double, scale: char): void
+equals(obj: Temperature): boolean
+isLessThan(obj: Temperature): boolean
+isGreaterThan(obj: Temperature): boolean
Method details
The name of a method explains it usage.
getDegreeInCelsius will return the temperature’s degree in its equivalent Celsius degree. If the temperature’s scale is ‘C’, then the return value is temperature’s degree. If the temperature’s scale is ‘F’, the return value is calculated by the following formula: C = (F-‐32)*5/9. For example, if the temperature degree is 77 and scale is ‘F’, then the method will return 25since (77-‐32)*5/9 = 25. For another example, if the temperature degree is 77 and scale is ‘C’, then the method will return 77.
getDegreeInFahrenheit will return the temperature’s degree in its equivalent Fahrenheit degree. If the temperature’s scale is ‘F’, then the return value is temperature’s degree. If the temperature’s scale is ‘C’, the return value is calculated by the following formula: F = 1.8C+32. For example, if the temperature degree is 25 and scale is ‘F’, then the method will return 25; For another example, if the temperature degree is 25 and scale is ‘C’, then the method will return 77 since 1.8*25+32 = 77.
void setDegree(double degree) will reset the temperature to given degree without change the scale of the temperature.
void setDegree(char scale) will reset the temperature to given scale without change the degree of the temperature.
void setDetree(double degree, char scale) will reset the temperature to given degree of given scale.
equals method returns true if this temperature is equal to parameter Temperature; false otherwise. You need to compare tow temperatures under same scale. For example, you either compare whether getDegreeInCelsius return same value for both temperatures, or whether getDegreeInFahrenheit return the same value for both temperatures.
isLessThan method return true if this temperature is less than parameter Temperature ; false otherwise. Again, you need to compare two temperatures under same scale.
isGreaterThan method returns true if this temperature is greater than parameter Temperature; false otherwise. Again, you need to compare two temperatures under same scale.
Main method requirements
The main method must create four Temperature objects by using all four constructors.
The main method must test all set and get methods by setting the attributes according to user’s input then displaying the temperature by printing out the result of get methods.
The main function must test equals, isLessThan, and isGreaterThan methods by compare two Temperature objects and print out the result.
Sample pseudo code for main function
Create a Temperature object by calling default constructor
Print out the temperature’s degree in Celsius
Print out the temperature’s degree in Fahrenheit
Ask user to enter the scale and degree of the temperature
Call set method(s) to set the temperature’s degree and scale
Print out the temperature’s degree in Celsius
Print out the temperature’s degree in Fahrenheit
Repeat step 1 to 7 for all other three constructorsto create three more temperatures
Test if temperature1 equals temperature2 and print out appropriate message
Test if temperature1 is less than temperature2 and print out appropriate message
Test if temperature1 is greater than temperature2 and print out appropriate message
Repeat step 9 to 11 for other pairs of temperatures
Note on main function and debugging
Fix one error a time.
If step 2 output is wrong, then either constructor is wrong or getDegreeInCelsiu function is wrong
If step 3 output is wrong, then either constructor is wrong or getDegreeInFahrenheit function is wrong
If step 6 output is wrong, then either set method(s) is wrong or getDegreeInCelsiu function is wrong
If step 7 output is wrong, then either set method(s) is wrong or getDegreeInFahrenheit function is wrong
If step 9 output is wrong, then the equals method has problem
If step 10 output is wrong, then the isLessThan method has problem
If step 11 output is wrong, then the isGreaterThan method has problem
*******************************MY CODE **********************************************
I tried to make this program but I had trouble with a few things, please complete the program and make sure it compiles. If possible, comment. Thank you
import java.util.Scanner;
public class Temperature
{
public static void main(String[] args) {
Temperature temp = new Temperature(0.0,C);
System.out.println("The first Temperature has been created using
the default constructor which sets");
System.out.println("the degree to a default value of " +
this.degree + "and the scale to a default value of " +
this.scale);
System.out.println("The first Temperature is " + getDegreeInCelsius
+ " C ");
System.out.println("The first Temperature is " +
getDegreeInFahrenheit + " F ");
Scanner in = new Scanner(System.in);
System.out.print("set the degree (a number) and the scale (F or C)
of the first Temperature.");
double degree = in.nextdouble();
System.out.print("First set the degree: " + this.degree);
//The first Temperature has been created using the default
constructor which sets
//the degree to a deafault value of 0.0 and the scale to a default
value of C.
//The first Temperature is 0.00 C.
//The first Temperature is 32.00 F.
//Set the degree (a number) and the scale (F or C) of the first
Temperature.
//First set the degree:
}
Temperature();
Temperature(double degree){
this.degree = degree;
}
Temperature(char scale){
this.scale = degree;
}
Temperature(double degree, char scale){
this.degree = degree;
this.scale = degree;
}
private double degree;
private char scale;
public double getDegreeInCelsius(){
if(scale == 'C' || scale == 'c'){
return degree;
}else {
return (degree - 32) * 5 / 9.0;
}
}
public double getDegreeInFahrenheit(){
if(scale == 'F' || scale == 'f'){
return degree;
}else {
return (1.8 * (degree) + 3.2);
}
}
public void setDegree(double degree) {
this.setDegree = degree;
}
public void setDegree(char scale) {
this.setDegree = scale;
}
public void setDegree(double degree, char scale) {
this.setDegree = degree;
this.setDegree = scale;
}
public boolean equals(){
if(this.getDegreeInCelsius() == obj.getDegreeInCelsius()){
return true;
}else if(this.getDegreeInFahrenheit() ==
obj.getDegreeInFahrenheit()){ {
return false;
}
}
public boolean isLessThan(Temperature temp){
if(this.getDegreeInCelsius() < temp.getDegreeInCelsius()){
return true;
}else if(this.getDegreeInFahrenheit() <
temp.getDegreeInFahrenheit()){
return true;
}else{
return false;
}
}
public boolean isGreaterThan(Temperature temp){
if(this.getDegreeInCelsius() > temp.getDegreeInCelsius()){
return true;
}else if(this.getDegreeInFahrenheit() >
temp.getDegreeInFahrenheit()){
return true;
}else{
return false;
}
}
In: Computer Science