Operating system
******Preemptive SJF************
The newly arrived process with shorter CPU burst will preempt the currently executing process.
Draw the Gantt Chart and calculate the average waiting time.
|
Process |
Arrival Time |
Burst Time |
Turn Around Time |
Waiting Time |
|
P4 |
0 |
5 |
||
|
P3 |
1 |
9 |
||
|
P2 |
2 |
4 |
||
|
P1 |
3 |
8 |
In: Computer Science
Run the following Java code and explain what it does.
Show the image created by the code.
public class Main{
public static void main(String[] args) {
new MyFrame();
}
}
import javax.swing.*;
public class MyFrame extends JFrame{
MyPanel panel;
MyFrame(){
panel = new MyPanel();
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.add(panel);
this.pack();
this.setLocationRelativeTo(null);
this.setVisible(true);
}
}
import java.awt.*;
import javax.swing.*;
public class MyPanel extends JPanel{
//Image image;
MyPanel(){
//image = new ImageIcon("sky.png").getImage();
this.setPreferredSize(new Dimension(500,500));
}
public void paint(Graphics g) {
Graphics2D g2D = (Graphics2D) g;
//g2D.drawImage(image, 0, 0, null);
g2D.setPaint(Color.blue);
g2D.setStroke(new BasicStroke(5));
g2D.drawLine(0, 0, 500, 500);
//g2D.setPaint(Color.pink);
//g2D.drawRect(0, 0, 100, 200);
//g2D.fillRect(0, 0, 100, 200);
//g2D.setPaint(Color.orange);
//g2D.drawOval(0, 0, 100, 100);
//g2D.fillOval(0, 0, 100, 100);
//g2D.setPaint(Color.red);
//g2D.drawArc(0, 0, 100, 100, 0, 180);
//g2D.fillArc(0, 0, 100, 100, 0, 180);
//g2D.setPaint(Color.white);
//g2D.fillArc(0, 0, 100, 100, 180, 180);
//int[] xPoints = {150,250,350};
//int[] yPoints = {300,150,300};
//g2D.setPaint(Color.yellow);
//g2D.drawPolygon(xPoints, yPoints, 3);
//g2D.fillPolygon(xPoints, yPoints, 3);
//g2D.setPaint(Color.magenta);
//g2D.setFont(new Font("Ink Free",Font.BOLD,50));
//g2D.drawString("U R A WINNER! :D", 50, 50);
}
}
In: Computer Science
Science Model
One share of Global Core Development Systems, Inc (an imaginary company with the abbreviation: Go-CDS) stock was priced at $14.59 on January 1, 2015. Your tasking in this problem is to determine how long does it take for a stockholder to double their money who has invested in Go-CDS? In other words, how long until the price per share has doubled.
Here are some facts about Go-CDS:
Write a MATLAB program to solve the following questions: Use matlab to make plot
1. In what month does the stock exceed 2 times the price of $14.59?
2. Prepare a plot of the stock's per-month price movement over the course starting from the first month of year 2017 until the price has exceeded 2 times the price of $14.59. (You plot should start from month 25, and should cover the month that is the answer to Question #1.) You will need to adjust the plot routine to ONLY show these months.
To limit the plot to these months, add the following command after your xlabel and ylabel commands:
| axis ([25, 56, 19, 31]) |
| xticks (0:4:length(P)) |
| yticks (0:2:31) |
In: Computer Science
I need the java code for a 4-function calculator app on android studio (do this on android studio). Please make sure all the requirements shown below are followed (such as the error portion and etc). The topic of this app is to simply create a 4 function calculator which calculates math expressions (add, subtract, multiply, and divide numbers).
The requirements are the following :
- The only buttons needed are 0-9, *, /, +, -, a clear, and enter button
- Implement the onclicklistener on the main activity
- The calcuator should use order of operations (PEMDAS)
- It should be able to continue from a previous answer (Ex: If you type 2+6 the calculator will display 8. If you then multiple by 2 the current result will simply be multiplied by 2)
- It should read the entire sequence of numbers and operators and save them into a String. The information can be read out of the String using a StringTokenizer. The delimiters will be the operators on the calculator.
- The entire mathematical expression will be displayed on the screen before the equal button is clicked.
- The equation will simply be evaluated in the order that the user types in the numbers rather than the precedence
- If the user enters an equation with invalid syntax, the output should display “error”. The calculator should also display “error” for any mathematical calculations that are impossible.
In: Computer Science
Java/JavaFX: Write up some simple sample code to demonstrate indirect recursion. You can just use print statements to demonstrate how they call one another.
Submit your working .java file here for credit.
In: Computer Science
*****************************************************
* USE UBUNTU (Linux) TERMINAL MODE COMMANDS ONLY *
* DO NOT USE ANY EDITORS TO CREATE THIS PROGRAM *
*****************************************************
1) Create a file called lastNameFirstNameInitialpgm3.sh ex: robinsonMpgm1.sh
2) Append to the above file the necessary commands that when this file is executed
it will display the following:
- Using your own set of multi-line comments enter your program identification
as described in the Syllabus, example:
<<ID
**************************************************
Author : Your Name
Course : Course Name and Times
Professor: Michael Robinson
Program : Program Number, Purpose/Description
A brief description of the program
Due Date : mm/dd/yyyy
I certify that this work is my own alone.
**************************************************
ID
- Append to the file the following commands that when this file is executed it will do the following:
1) Display Hello my name is:
2) Display My user name is:
3) Display Todays date and time is:
4) Display This file has x lines
5) Display This file has x words
6) Display this file has x bytes
7) Display Please enter any number
8) Display Your number $number * 2 = XXX and display press any key to continue
9) Display a new clean screen
10) Display Enter a line of numbers to be added
11) Using enhanced for loop, display all numbers entered delaying the output
of each number by 1 second each and then the total of adding thoses numbers:
ex: 20 5 3 = 28
12) Using a while true loop request, accept and display data until it ends on
input mod 5 = 0
using -lt and -gt comparison commands
this uses if else
In: Computer Science
In: Computer Science
Instead of using two different variables, however, we will
define a structure with two members; one representing the feet and
the other one representing the inches. We will also use three
functions; one to initialize a structure, another one to check the
validity of its values, and one last one to print them out.
First, go ahead and define your structure. Next, declare a
structure of this type inside the main. Then, call your first
function (the initialization function). This function will be of
type structure, it will receive zero parameters and it will return
a structure. Inside the function, ask the user for the height of
the student. In other words, you will use this function to
initialize the structure you have in the main. When done, call a
second function (the checking function). To this function, you will
send your structure. The function will not return anything and it
will validate the values inputted by the user. If any of the values
is not in the right range (between 5’ 8” and 7’ 7”), display an
error message and exit the program. Make sure to also check for
negative values.
Lastly, if the program didn’t exit, call the last function (the
printing function). This function will receive a structure, it will
not return anything and it will display the values of the two
members of the structure.
Use C code to solve this problem.
In: Computer Science
Compare and contrast the functionalities of TCP wrappers and a firewall.
In: Computer Science
Your organization has created a data-sharing partnership with another business. Management of both organizations has decided they want to share data between their networks via FTP. Data sharing will occur between known, existing servers on each side of the network. You have been asked to devise a firewall-specific strategy to facilitate this new connection. What strategy
would you recommend, and why?
Your answer should be approximately 200-250 words in length
In: Computer Science
A consultant has recommended your organization look to increase its security profile in relation
to SMTP traffic. Management has asked you devise a firewall-specific strategy to address the
recommendation. What strategy would you recommend, and why?
Your answer should be approximately 200-250 words in length.
In: Computer Science
In this lab, you will implement Heap Sort algorithm in C++ and Report the number of steps and the CPU running time in a table,
Approximation the constant c in the complexity of heap sort (cnlgn) by inspecting the results
For each algorithm, and for each n = 100, 200, 300, 400, 500, 1000, 4000, 10000, measure its running time and number of steps when the input is (1) already sort, i.e. n, n-1, …, 3, 2,1; (2) reversely sorted 1, 2, 3, … n; (3) random permutation of 1, 2, …, n; (4) 50 instances of n random numbers generated in the range of [1..n].
In: Computer Science
Make a 20 by 20 matrix in which diagonal elements are 21, 22, 23, 24 … 40 and elements below the diagnol are ij = 2(i 2 j 2 ) and elements above the diagnol are 4×(i+j) Note: You must use if, elseif, else, end or/and if, end or/and if, else, end commands in MATLAB.
In: Computer Science
Write an algorithm to find the primary key and foreign key(s)?
(Every programming language is accepted.)
In: Computer Science
Design and construct a computer program in one of the approved languages (C, C++, C#, Java, Pascal, Python, etc.) that will illustrate the use of a fourth-order explicit Runge-Kutta method of your own design. In other words, you will first have to solve the Runge-Kutta equations of condition for the coefficients of a fourth-order Runge-Kutta method. See the Mathematica notebook on solving the equations for 4th order RK method. .DO NOT USE a[1] or a[2] = 1/2. Then, you will use these coefficients in a computer program to solve the ordinary differential equation below. Be sure to follow the documentation and programming style policies of the Computer Science Department. The initial value problem to be solved is the following: x'(t) = 2 x2 cos(4 t) subject to the initial condition: x(0) = 1.0 Obtain a numerical solution to this problem over the range from t=0.0 to t=2.0 for seven different values of the stepsize, h=0.1, 0.05 , 0.025 , 0.0125 , 0.00625 , 0.003125 , and 0.0015625 .
The answer at the end of the integration is about 1.978940602164785990777661.
Hint: It is often helpful to test your program on simple
differential equations (such as x' = 1 or x'=t or x'=x) as a part
of the debugging process.
Once you have worked these simple cases, then try working the
nonlinear differential equation given above for the assignment
(with a small stepsize).
Also, check your coefficients to make sure that they satisfy the
equations of condition and that you have assigned these correct
values to the
variables or constants in your program properly. For example, a
common error is to write something like: a2 =
1/2; when you meant to write
a2 = 1.0/2.0; so please be
careful.
Write down (in your output file or in a text file) any conclusions that you can make from these experiments (e.g., what happens as h is decreased?).
In: Computer Science