Question

Find the error in this Java code. (Hint: think about scope!) Imagine that the variables rewinding...

Find the error in this Java code. (Hint: think about scope!)

Imagine that the variables rewinding and playbackPosition could have different values depending on the situation.

double playbackPosition = 120;

boolean rewinding = true;

if (rewinding) {

double rewindAmount = 0.1;

}

playbackPosition = playbackPosition - rewindAmount;

0 0
Add a comment Improve this question Transcribed image text
Answer #1
double playbackPosition = 120;
boolean rewinding = true;
double rewindAmount = 0.0;
if (rewinding) {
  rewindAmount = 0.1;
}
playbackPosition = playbackPosition - rewindAmount;

Add a comment
Know the answer?
Add Answer to:
Find the error in this Java code. (Hint: think about scope!) Imagine that the variables rewinding...
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
  • I'm working with Java and I have a error message  1 error Error: Could not find or...

    I'm working with Java and I have a error message  1 error Error: Could not find or load main class Flowers. This is the problem: Instructions Make sure the source code file named Flowers.java is open. Declare the variables you will need. Write the Java statements that will open the input file, flowers.dat, for reading. Write a while loop to read the input until EOF is reached. In the body of the loop, print the name of each flower and where...

  • 12) 8 pts. Find the errors in the following code fragment and correct them. #i nclude...

    12) 8 pts. Find the errors in the following code fragment and correct them. #i nclude <iostream> using namespace std; double fudge (double s) f return s 2.3; int mainO cout >> "Your original estimate" double estimate; cin >> estimate; cout << endl; for (int 1 = 0;1c3;i++); cout << "EStimate' < fudge(estimate) <<endl Hint: There are 4 syntax errors. There is one error that is syntactically correct but causes the output to not be what you would expect. Once...

  • Please help me with this code. Thank you Implement the following Java class: Vehicle Class should...

    Please help me with this code. Thank you Implement the following Java class: Vehicle Class should contain next instance variables: Integer numberOfWheels; Double engineCapacity; Boolean isElectric, String manufacturer; Array of integers productionYears; Supply your class with: Default constructor (which sets all variables to their respective default values) Constructor which accepts all the variables All the appropriate getters and setters (you may skip comments for this methods. Also, make sure that for engineCapacity setter method you check first if the vehicle...

  • In JavaScript the inner function can access the variables from the outer scope even after the...

    In JavaScript the inner function can access the variables from the outer scope even after the outer function has returned. This is because the variables are still bound in the inner function and not dependent on the outer function. This is called closure. True False 3 points    QUESTION 2 Which of the following statements is true about JSON? a. JSON stands for JavaScript Object Notation. b. JSON is a syntax for storing and exchanging data. c. JSON is text,...

  • use java follow my code: public class q1 {    // Instance Variables    int currentFloor;...

    use java follow my code: public class q1 {    // Instance Variables    int currentFloor;    double maximumWeight;    int topFloor;       // Constructor Declaration of Class    public q1 (int currentFloor, double maximumWeight, int topFloor)    {    this.currentFloor = currentFloor;    this.maximumWeight = maximumWeight;    this.topFloor = topFloor;    }       // Property to get value of currentFloor instance variable    public int getCurrentFloor()    {    return currentFloor;    }       // Property...

  • Please write a code in Java where it says your // your code here to run...

    Please write a code in Java where it says your // your code here to run the code smoothly. Import statements are not allowed. _ A Java method is a collection of statements that are grouped together to perform an operation. Some languages also call this operation a Function. When you call the System.out.println() method, for example, the system actually executes several statements in order to display a message on the console. Please write the code according to functions assigned...

  • Please write a code in Java where it says your // your code here to run...

    Please write a code in Java where it says your // your code here to run the code smoothly. Import statements are not allowed for this assignment, so don't use them. _ A Java method is a collection of statements that are grouped together to perform an operation. Some languages also call this operation a Function. When you call the System.out.println() method, for example, the system actually executes several statements in order to display a message on the console. Please...

  • Create a new program in Mu and save it as ps3.2.2.py and take the code below...

    Create a new program in Mu and save it as ps3.2.2.py and take the code below and fix it as indicated in the comments: egg = True milk = True butter = True flour = True # You may modify the lines of code above, but don't move them! # When you Submit your code, we'll change these lines to # assign different values to the variables. # Imagine you're deciding what you want to cook. The boolean # variables...

  • [Java] PLEASE FIX MY CODE I think I'm thinking in wrong way. I'm not sure what...

    [Java] PLEASE FIX MY CODE I think I'm thinking in wrong way. I'm not sure what is wrong with my code. Here'e the problem: Write a class SemiCircle that represents the northern half of a circle in 2D space. A SemiCircle has center coordinates and a radius. Define a constructor: public SemiCircle(int centerX, int centerY, int theRadius) Implement the following methods: public boolean contains(int otherX, int otherY) returns true if the point given by the coordinates is inside the SemiCircle....

  • I need java code for the following problem. Lab 7: Methods 1. Write a Java program called Numbers that calls the following methods and displays the returned value: Write a method called cubelt that a...

    I need java code for the following problem. Lab 7: Methods 1. Write a Java program called Numbers that calls the following methods and displays the returned value: Write a method called cubelt that accepts one integer parameter and returns the value raised to the third power as an integer. o Write a method called randominRange that accepts two integer parameters representing a range. The method returns a random integer in the specified range inclusive. 2. o Write a method...

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