USE FOR LOOP INSTEAD OF WHILE
LOOP
I have wrote simple java program, to provide the value which you
asked for. Looks like you code is little incomplete, still i tried
to make it..
public class HelloWorld{
public static void main(String []args){
int k=1, b=-2, x=-2, y=-2;
for(;k <= 3; k++){
y = x*x - 3;
System.out.println(k + " " + b + " " + x + " " + y);
}
}
}
Sample Output:
So
Pass | k | b | x | y |
1st | 1 | -2 | -2 | 1 |
2nd | 2 | -2 | -2 | 1 |
3rd | 3 | -2 | -2 | 1 |
4th | Loop not executed | |||
5th | Loop not executed |
USE FOR LOOP INSTEAD OF WHILE LOOP Consider the following script file. Fill in the lines...
Use a while-end loop in a script file to calculate the sum of the first n terms of the series: sigma_k=1^n (-1)^kl^2 + 5k/3^k. Show the script file and the two results of n = 10 and n = 20. (b) Use a for-end loop in a script file to calculate the sum of the first n terms of the series: sigma_k=1^n (-1)^kl^2 + 5k/3^k. Show the script file and the two results of n = 10 and n =...
Using mat lab to do it
Create a single script file named yourname_While.m to answer the following problems. The file must be in cell mode to distinguish each problem. Make sure your script is nicely commented for each problem. Consider the following matrix of values: x =[345, 23, 17, 34, 85, 334, 111, 1067] Use a for loop and if statement to determine how many values greater than 30? Use fprintf to display the result. Repeat Problem 1., but use...
write matlab script
5. Use a for loop to sum the elements in x = [1 2 3 4 5] Check your answer with sum function 6. Use a while loop to sum the elements in x = [1 2 3 4 5] Check your answer with sum function
Copy/Paste your script from 5b here.
4. Let's look at a more complicated script executable. a. Write the following as script6.sh and change its permissions to count for num in d do if num eq 100 then count (count+1) done echo The number 10 was found $count times What is the output? Run the script as ./script6.sh 10 20 30 10 40 20 50 10 60 <enter Summarize what the script does r using the read command. The following script...
Problem 1: Use MATLAB to create a script file and publish a pdf file for the problem: For x equal to 1.5 at intervals of 0.05 y = 6.25 +1.8 Create a rectangular plot of x&y. Submit the published pdf file. Problem 2: Use MATLAB to create a script file and publish a pdf file for the problem: Create a bar chart for Grade А B Students 48 37 29 2 6 D F Submit the published pdf file. Problem...
THE CODE NEEDS TO BE ON MATLAB
2. Exercise (a) Let's write a script file that calculates exp(2) by a Maclaurin series using a while loop exp x )=-+-+-+-+ The while loop should add each of the series terms. The program error as defined below is smaller than 0.01. Error is the exact value (i.e. exp(2)), minus the approximate value (i.e., the current series sum) should exit the loop when the absolute absolute error-lexact-approx Use fprintf within the loop such...
10) you will run/call the function with these given values. (b) Write a flow chart and the script file using conditional statements with logical operator if/else and if/elseif, to evaluate the following function, assuming that the scalar x has a value: y 2 sin(m) for-1 x < 5 y=10(X-5) + 1 for x 25 Use your file to evaluate y for x5,x 3 and x 15 by hand
10) you will run/call the function with these given values. (b) Write...
For this Linux script, answer the questions following it: # Sort lines 7 - 26 of the file BEGIN { idx = 1; while (getline line<"makefile" ) { data[idx] = line; idx++; } for (idx2 = 7; idx2 <= 26; idx2++) { data2[idx2 - 6] = data[idx2]; } count = asort(data2); for (idx3 = 1; idx3 < 7; idx3++) { print data[idx3]; } for (idx3 = 1; idx3 <= 20; idx3++) { print data2[idx3]; } for (idx3 = 27; idx3...
Write a Script file ‘run-divisiblity-check·m'. Run a for loop from 1 to 100 with an increment of 1 and using if-else statement print whether the current number in the loop is divisible by 2, 3 or both or neither rem0 command in MATLAB tells the remainder of a variable when divided by a particular number. For instance, if x-3, rem(x, 2) would return 1 and if x-2, rem(x, 2) would be 0 Do a help on rem() command if you...
please help, this is so urgent, multiple question 14
14. After executing the following script file in MATLAB X1 = [1 0 2; -1 50; 0 3 -9]; Xinvi= inv(x1); Xinvinv= Xinv2*X2 the displayed result is a b. 0.0000 0 0 0.0000 -0.0000 0.0000 -0.0000 -0.0000 0.0000 b. error c. 03 -9 -150 102 d. 1.0000 0.0000 -0.0000 0 1.0000 0.0000 0 -0.0000 1.0000 e. none of above 15. After executing the following script file in MATLAB a =17; while...