1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Nutka1998 [239]
3 years ago
11

Can someone reply me

Computers and Technology
1 answer:
Georgia [21]3 years ago
4 0
Yes how can i help you?
You might be interested in
This project must target a Unix platform and execute properly on our CS1 server.
sweet-ann [11.9K]

Answer:

hope this helps ,if it did pls do consider giving brainliest

Explanation:

// Java program for implementation of FCFS scheduling

import java.text.ParseException;

class GFG {

// Function to find the waiting time for all

// processes

static void findWaitingTime(int processes[], int n,

int bt[], int wt[]) {

// waiting time for first process is 0

wt[0] = 0;

// calculating waiting time

for (int i = 1; i < n; i++) {

wt[i] = bt[i - 1] + wt[i - 1];

}

}

// Function to calculate turn around time

static void findTurnAroundTime(int processes[], int n,

int bt[], int wt[], int tat[]) {

// calculating turnaround time by adding

// bt[i] + wt[i]

for (int i = 0; i < n; i++) {

tat[i] = bt[i] + wt[i];

}

}

//Function to calculate average time

static void findavgTime(int processes[], int n, int bt[]) {

int wt[] = new int[n], tat[] = new int[n];

int total_wt = 0, total_tat = 0;

//Function to find waiting time of all processes

findWaitingTime(processes, n, bt, wt);

//Function to find turn around time for all processes

findTurnAroundTime(processes, n, bt, wt, tat);

//Display processes along with all details

System.out.printf("Processes Burst time Waiting"

+" time Turn around time\n");

// Calculate total waiting time and total turn

// around time

for (int i = 0; i < n; i++) {

total_wt = total_wt + wt[i];

total_tat = total_tat + tat[i];

System.out.printf(" %d ", (i + 1));

System.out.printf(" %d ", bt[i]);

System.out.printf(" %d", wt[i]);

System.out.printf(" %d\n", tat[i]);

}

float s = (float)total_wt /(float) n;

int t = total_tat / n;

System.out.printf("Average waiting time = %f", s);

System.out.printf("\n");

System.out.printf("Average turn around time = %d ", t);

}

// Driver code

public static void main(String[] args) throws ParseException {

//process id's

int processes[] = {1, 2, 3};

int n = processes.length;

//Burst time of all processes

int burst_time[] = {10, 5, 8};

findavgTime(processes, n, burst_time);

}

}

// Java program to implement Shortest Job first with Arrival Time

import java.util.*;

class GFG {

static int[][] mat = new int[10][6];

static void arrangeArrival(int num, int[][] mat) {

for (int i = 0; i < num; i++) {

for (int j = 0; j < num - i - 1; j++) {

if (mat[j][1] > mat[j + 1][1]) {

for (int k = 0; k < 5; k++) {

int temp = mat[j][k];

mat[j][k] = mat[j + 1][k];

mat[j + 1][k] = temp;

}

}

}

}

}

static void completionTime(int num, int[][] mat) {

int temp, val = -1;

mat[0][3] = mat[0][1] + mat[0][2];

mat[0][5] = mat[0][3] - mat[0][1];

mat[0][4] = mat[0][5] - mat[0][2];

for (int i = 1; i < num; i++) {

temp = mat[i - 1][3];

int low = mat[i][2];

for (int j = i; j < num; j++) {

if (temp >= mat[j][1] && low >= mat[j][2]) {

low = mat[j][2];

val = j;

}

}

mat[val][3] = temp + mat[val][2];

mat[val][5] = mat[val][3] - mat[val][1];

mat[val][4] = mat[val][5] - mat[val][2];

for (int k = 0; k < 6; k++) {

int tem = mat[val][k];

mat[val][k] = mat[i][k];

mat[i][k] = tem;

}

}

}

// Driver Code

public static void main(String[] args) {

int num;

Scanner sc = new Scanner(System.in);

System.out.println("Enter number of Process: ");

num = sc.nextInt();

System.out.println("...Enter the process ID...");

for (int i = 0; i < num; i++) {

System.out.println("...Process " + (i + 1) + "...");

System.out.println("Enter Process Id: ");

mat[i][0] = sc.nextInt();

System.out.println("Enter Arrival Time: ");

mat[i][1] = sc.nextInt();

System.out.println("Enter Burst Time: ");

mat[i][2] = sc.nextInt();

}

System.out.println("Before Arrange...");

System.out.println("Process ID\tArrival Time\tBurst Time");

for (int i = 0; i < num; i++) {

System.out.printf("%d\t\t%d\t\t%d\n",

mat[i][0], mat[i][1], mat[i][2]);

}

arrangeArrival(num, mat);

completionTime(num, mat);

System.out.println("Final Result...");

System.out.println("Process ID\tArrival Time\tBurst" +

" Time\tWaiting Time\tTurnaround Time");

for (int i = 0; i < num; i++) {

System.out.printf("%d\t\t%d\t\t%d\t\t%d\t\t%d\n",

mat[i][0], mat[i][1], mat[i][2], mat[i][4], mat[i][5]);

}

sc.close();

}

}

7 0
3 years ago
Complete the method, longestWord(), below that takes in an array of Strings and returns the longest String in the array. Note: y
beks73 [17]

Answer:

I am writing a JAVA program.

public class StringMethod {

public static String longestWord(String []words) { //method that takes an array  "word" of strings and returns the longest string in the array word

    int pos = 0; // contains index of the longest word of array words

    int longest = words[0].length(); //initially holds the length of the 1st element of words array

    for(int i=1; i< words.length; i++) { // iterates through each word of the array until the end of array

        if(words[i].length() > longest) { // if the length of word at i-th index of words[] is greater than the length of the word that is contained in longest variable

            pos = i; // assigns the index of the longest array element to pos

            longest = words[i].length();    } } //assigns the word in words[] array with the longest length to longest variable

   return words[pos]; } // returns the longest string in the array    

public static void main(String[] args) { //start of main() function body

String[] animals = {"cat", "horse", "elephant", "bird"}; //creates a String type array named animals which has 4 elements/words

   String longest_word= longestWord(animals); //calls longestWord method to find the longest string in the array animals and assign that longest string to longest_word.

  System.out.println(longest_word); }} //displays the longest word in output

Explanation:

Suppose we have the array of these elements: "cat", "horse", "elephant", "bird" These are four words in the array. Now lets see how the method longestWord() works:

int pos = 0; This variable is initialized to 0.

int longest = words[0].length();

longest holds the length of element at 0th index of words[] array. length() method is used to return the length of the first element words[0] array.

As the first element of array is "cat" so length of cat is 3. Hence longest = 3

for(int i=1; i< words.length; i++)

The loop has a variable i which is initialized to 1. The loop checks if the value of i is less than length of words[] array. The length of words array is 4 as there are 4 elements i.e. cat, horse, elephant and bird in this array. So the condition evaluates to true because i<words.length i.e. 1<4. The body of the loop will execute now. The body of loop contains an if condition if(words[i].length() > longest) which checks if the length of element of array at i-th index is greater than length of the element that is stored in longest variable. As i=1 so word[i] is word[1] which is the second element of words[] array. The second element is horse.

words[i].length()  means the length of i-th element of words[] array. So this means words[1].length() i.e. the length of element of words[] at 1st index. The length of horse is 5. So the statement if(words[i].length() > longest) is true because longest=3 and words[1].length() = 5 and 5>3. So the statements of if condition will execute now.

pos = i; this variable pos is used to hold the index position of the longest element in array. So pos = 1 as longest element computed so far is "horse".

longest = words[i].length(); This statement then assigns the length of horse to longest. So now the value of longest = 5

At second iteration i is now 2.  Loop condition evaluates to true because i<words.length i.e. 2<4. If condition is also true as i=2 so word[i] is word[2] which is elephant.

words[i].length() now means words[2].length() i.e. the length of element of words[] at 2nd index. The length of elephant is 8. So the statement if(words[i].length() > longest) is true because longest=5 and words[2].length() = 8 and 8>5. So the statements of if condition will execute now.

pos = i; now becomes pos = 2 as longest element computed so far is "elephant".

longest = words[i].length();  This statement then assigns the length of horse to longest. So now the value of longest = 8

At third iteration i is now 3.  The loop again checks if the value of i is less than length of words[] array.The condition evaluates to true because i<words.length i.e. 3<4. The body of the loop will execute now.  if(words[i].length() > longest) checks if the length of element of array at i-th index is greater than length of the element that is stored in longest variable. As i=3 so word[i] is word[3] which is the fourth element of words[] array. The fourth element is bird.

words[i].length() now means words[3].length() i.e. the length of element of words[] at 3rd index. The length of bird is 4. So the statement if(words[i].length() > longest) is false because longest=8 and words[2].length() = 4 and 4<8. So the statements of if condition will not execute now.

At fourth iteration i is now 4.  The loop again checks if the value of i is less than length of words[] array.The condition evaluates to false because i==words.length i.e. 4=4. So the loop breaks.

 return words[pos]; statement returns the index position of longest word in words[] array. pos = 2 So the array element at 2nd index is basically the third element of array words[] i.e. elephant. So the longest string in the array is elephant.

8 0
3 years ago
What is the relationship between a base and the number of symbols in a positional number system​?
Leni [432]

Answer:

the value of a symbol is given by the weight of it's position expressed in the bases of the system (or radices)

6 0
3 years ago
What is the difference between onlinenews and printed newspaper​
oee [108]

Answer:

The difference between onlinenews and printed newspaper are that one of them is representing topics about the world and the other one just basically proves facts about why the world is a nasty place at this point.

Explanation:

6 0
3 years ago
Read 2 more answers
What major criteria must a product or process meet in order to be considered emerging technology?
Korvikt [17]
The major criteria that a product or process should have in order to be considered as an emerging technology are its favorability. The product or process should be properly studied and examined if it may or may not favor the actions of your industry, most specifically to the environmental factors. 
8 0
3 years ago
Read 2 more answers
Other questions:
  • 1.) How do parks and other green spaces benefit a community?
    10·1 answer
  • Which of the following are advantages of cloud computing?
    6·2 answers
  • Which player type focuses on level progression?
    13·1 answer
  • HELP 10 POINTS AND BRAINLIEST FOR BEST ANSWER! EASY I PROMISE! HELPFUL ANSWERS ONLY PLEASE HURRY!
    14·2 answers
  • My sister put my phone in the microwave and I'm pretty sure the battery blew up. I'm too scared to open the microwave. What do I
    11·1 answer
  • What software maintain and increase the efficiency of a computer system?
    12·1 answer
  • What help in executing commands quickly
    5·1 answer
  • These principles are essential to the design and development and production of clothing
    15·1 answer
  • Please help with question
    14·1 answer
  • To meet the requirement for the number of vdss on board, what must be true about pyrotechnic vdss?
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!