IN PYTHON
Develop a program in python that includes a number of functions for the multi-server queue. The program accepts arrival and services rates and the number of servers and calls your functions to output the average number of customers and average waiting time in the system.
In: Computer Science
Implement a class named Complex that represents immutable complex numbers.
Code Given:
import java.util.Arrays;
import java.util.List;
/**
* A class that represents immutable complex numbers.
*
* @author EECS2030 Fall 2019
*
*/
public final class Complex {
/**
* Initializes this complex number to <code>0 +
0i</code>.
*
*/
public Complex() {
}
/**
* Initializes this complex number so that it has the
same real and
* imaginary parts as another complex number.
*/
public Complex(Complex other) {
}
/**
* Initializes this complex number so that it has the
given real
* and imaginary components.
*/
public Complex(double re, double im) {
}
/**
* A static factory method that returns a new complex
number whose real part
* is equal to re and whose imaginary part is equal to
0.0
*/
public static Complex real(double re) {
return null;
}
/**
* A static factory method that returns a new complex
number whose real part
* is equal to 0.0 and whose imaginary part is equal to
im
*/
public static Complex imag(double im) {
return null;
}
/**
* Get the real part of the complex number.
*/
public double re() {
return 0.0;
}
/**
* Get the imaginary part of the complex number.
*/
public double im() {
return 0.0;
}
/**
* Add this complex number and another complex number
to obtain a new
* complex number. Neither this complex number nor c is
changed by
* this method.
*/
public Complex add(Complex c) {
return null;
}
/**
* Multiply this complex number with another complex
number to obtain a new
* complex number. Neither this complex number nor c is
changed by
* this method.
*/
public Complex multiply(Complex c) {
return null;
}
/**
* Compute the magnitude of this complex number.
*/
public double mag() {
return 0.0;
}
/**
* Return a hash code for this complex number.
*/
@Override
public int hashCode() {
return 0;
}
/**
* Compares this complex number with the specified
object. The result is
* <code>true</code> if and only if the
argument is a <code>Complex</code>
* number with the same real and imaginary parts as
this complex number.
*/
@Override
public boolean equals(Object obj) {
return true;
}
/**
* Returns a string representation of this complex
number.
*/
@Override
public String toString() {
return "";
}
/**
* Returns a complex number holding the value
represented by the given
* string.
*/
public static Complex valueOf(String s) {
Complex result = null;
String t = s.trim();
List<String> parts =
Arrays.asList(t.split("\\s+"));
// split splits the string s by
looking for spaces in s.
// If s is a string that might be
interpreted as a complex number
// then parts will be a list having
3 elements. The first
// element will be a real number,
the second element will be
// a plus or minus sign, and the
third element will be a real
// number followed immediately by
an i.
//
// To complete the implementation
of this method you need
// to do the following:
//
// -check if parts has 3
elements
// -check if the second element of
parts is "+" or "-"
// -check if the third element of
parts ends with an "i"
// -if any of the 3 checks are
false then s isn't a complex number
// and you should throw an
exception
// -if all of the 3 checks are true
then s might a complex number
// -try to convert the first
element of parts to a double value
// (use Double.valueOf); this might
fail in which case s isn't
// a complex number
// -remove the 'i' from the third
element of parts and try
// to convert the resulting string
to a double value
// (use Double.valueOf); this might fail in which case
s isn't
// a complex number
// -you now have real and imaginary
parts of the complex number
// but you still have to account
for the "+" or "-" which
// is stored as the second element
of parts
// -once you account for the sign,
you can return the correct
// complex number
return result;
}
}
In: Computer Science
In: Computer Science
How can I identify products and their characteristics that resemble the alpha, beta and chi models? Thanks in advance.
FOR EXAMPLE: 1. Microsoft’s Office Products which resembles chi;
2. AMAZON -- at one point, Amazon considered cloud services to be its beta product;
3. Mondalez’s Oreo cookies could be an alpha.
In: Computer Science
How can I prove that finding the minimum or maximum of n numbers has a lower bound of Ω(n) for any comparison-based algorithm.
In: Computer Science
How do you add all the values that return by all the
threads from threadpools?
I have created a threadpool with 1000 of threads and run the task
1000 times. However, when I try to print out the result it gives a
whole bunch of values that return by all the threads, it looks
like...
Thread-1 xxxx
Thread-2 xxxx
Thread-3 xxxx
Thread-4 xxxx
.
.
.
.
.
Is there a possible way to get a single value back instead of whole bunch of value? Taking the average value of all the threads are fine as well.
This question is based on Java only. Thank you!!
In: Computer Science
How can i calculate this?
A file of size F = 8 Gbits needs to be distributed to10 peers. Suppose the server has an upload rate of u = 68 Mbps, and that the 10 peers have upload rates of: u1 = 20 Mbps, u2 = 22 Mbps, u3 = 12 Mbps, u4 = 19 Mbps, u5 = 25 Mbps, u6 = 24 Mbps, u7 = 18 Mbps, u8 = 11 Mbps, u9 = 14 Mbps, u10 = 30 Mbps, and download rates of: d1 = 28 Mbps, d2 = 30 Mbps, d3 = 12 Mbps, d4 = 20 Mbps, d5 = 18 Mbps, d6 = 15 Mbps, d7 = 14 Mbps, d8 = 34 Mbps, d9 = 20 Mbps, d10 = 34 Mbps. What is the minimum time needed to distribute this file from the central server to the 10 peers using the client-server model (round to the nearest second)?
In: Computer Science
How to write this mini program in C# - (C sharp please)
There are 3 squirrels and winter begins in roughly 12 weeks
Each week, a squirrel will manage to stash away anywhere
from 10 to 20 acorns
Each week, display the following:
◦
The number of weeks before winter
◦
The number of acorns each squirrel stashed away that week
◦
The total number of acorns each squirrel has stashed away
Bonus: display the number of acorns stashed each month as
asterisks (*)
In: Computer Science
In: Computer Science
Write an interactive program that inputs a decimal num1 and an
integer num2. If num1 is less than num2, then it displays "num 1 is
less than num 2"; if they are identical, it starts over again; if .
If num2 is less than num1, then it displays "num 2 is less than num
1
In: Computer Science
2. Consider these declarations: ArrayList stringList = new ArrayList(); String ch = “ ”; Integer intOb = new Integer(5);
For the following statements, indicate VALID or INVALID (invalid if the statement causes an error)
A. strList.add(ch); _______________
B. strList.add(new String(“handy andy”); ______________
C. strList.add(intOb.toString()); ____________
D. strList.add(ch + 8); _________________
E. strList.add(intOb + 8); ____________
In: Computer Science
#4 You need to write a class MinMax with a method minmax that takes an array of integers as a parameter and returns min and max simultaneously (using one method and one call). (java oop)-> laboratory work
In: Computer Science
Draw a UDP segment, identify its header fields, and provide a brief description for each one of them
In: Computer Science
A perceptron with a unipolar step function has two inputs with weights w1= 0.5 and w2= -0.2, and a threshold theta=0.3 (theta can therefore be considered as a weight for an extra input which is always set to -1). The perceptron is trained using the learning rule ∆w = η (d − y) x, where x is the input vector, η is the learning rate, w is the weight vector, d is the desired output, and y is the actual output.What are the new values of the weights and threshold after one step of training with the input vector x = [0, 1]^T and desired output 1, using a learning rate η = 0.5?
In: Computer Science
Im working with visual basics for these problem.
1) Write a program that accepts five integers, and for each integer following the first, prints "GREATER" or "LESS" depending on whether or not the current integer is greater than the previous one. At the end, your application will let user know the largest and the smallest of the five numbers provided
(BONUS): consider using the concepts of swapping the current and previous values as needed and don't use 5 variables.
In: Computer Science