Answer:
import java.util.Scanner;
// Needed for the Scanner class This program calculates the user's gross pay.
public class Pay {
public static void main(String[] args) {
// Create a Scanner object to read from the keyboard.
Scanner keyboard = new Scanner(System.in);
// Identifier declarations
double hours;
// Number of hours worked
double rate;
// Hourly pay rate
double pay;
// Gross pay
// Display prompts and get input.
System.out.print("How many hours did you work? ");
hours = keyboard.nextDouble();
System.out.print("How much are you paid per hour? ");
rate = keyboard.nextDouble();
// Perform the calculations.
if (hours <= 40) {
pay = hours * rate;
}
else
{
pay = (hours - 40) - (1.5 * rate) + 40 - rate;
}
// Display results.
System.out.println("You earned $" + pay);
}
}
Explanation:
Answer:
def insSort(arr):
ct=0;
for i in range(1, len(arr)):
key = arr[i]
j = i-1
while j >=0 and key < arr[j] :
arr[j+1] = arr[j]
j -= 1
ct=ct+1;
arr[j+1] = key
return arr,ct;
print(insSort([2,1]))
Output of the program is also attached.
Answer:
Output explanation to the given code can be defined as follows:
Explanation:
In A the output is 0
, It will return fork value of the child process that is 0. so, 0 is printed during child process.
In B the output is 2650
, in which the getpid() method returns the child process id value that is 2650.
In C the output is 140, As it is declared in key, all process have their own "value" copies. 20 are inserted during childhood, so 140 are written.
In D the output is 2650, its fork() method returns the child ID to the parent process. so the value 2650 is printed.
In E the output is 2600, Its getpid() method will returns parent process id that is equal to 2600.
In F the output is 120 Since the value is declared in primary, all process so their own "value" copies. 120 will be printed during process.
Answer:
Option A is the correct answer choice for the above question.
Explanation:
The computer system needs intercommunication which is done inside the processor to process the task given by the user. There are two types of model is used for intercommunication--
- Message passing and
- Shared memory
The difference between two is that message passing passes the message on two points at a single unit of time whereas shared memory simultaneous shares the multiple messages. That's why shared memory is faster than message passing.
- Hence option A is the correct choice because it also refers to the above concept. While the other is not correct because--
- Option B states that message passing is faster than shared memory which is wrong.
- Option C states that message passing is used for large data but shared memory is used for large data.
- Option D states that shared memory is unavailable in some processor which is wrong.
Answer:
A lot is wrong with the program given in the question. See the corrected version below:
<em>public class ANot {</em>
<em> public static void main(String[] args) {</em>
<em> int a, b, c;</em>
<em> //Three integers</em>
<em> a = 3; b = 4; c = a + b;</em>
<em> System.out.println("The value of c is " + c);</em>
<em> }</em>
<em>}</em>
Explanation:
Errors:
1. The main method had a semi colon after it. This is wrong
2. An open brace was supposed to follow the main method
3. The declaration of the variables was supposed to end with a semi colon
4. the correct comment style is // and not \\
5. Initialization of variables was supposed to end with semi colons
6. The output statement had C and not c which is the declared and initialized variable..Java is strictly typed
7. Open and closing braces for the class and method wrongly placed