Question

Consider the following script file. Fill in the lines of the following table with the values that would be displayed immediately after the while statement if you ran the script file. Write in the values the variables have each time the while statement is executed. You might need more or fewer lines in the table. Then type in the file, and run it to check your answers. if y 2 x 2 while k 3 k, b, x, y Pass First Second Third Fourth FifthUSE FOR LOOP INSTEAD OF WHILE LOOP

0 0
Add a comment Improve this question Transcribed image text
Answer #1

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:
Default Term Browser sh-4.3$ javac Helloworld.java sh-4.3$ java -Xmx128M -Xms 16M Helloworld sh-4.3$


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
Add a comment
Know the answer?
Add Answer to:
USE FOR LOOP INSTEAD OF WHILE LOOP Consider the following script file. Fill in the lines...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Use a while-end loop in a script file to calculate the sum of the first n...

    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...

    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...

    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....

    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 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...

    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 fo...

    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...

    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...

    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...

    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...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT