Find three errors in the Java program below generated by the Java compiler. Indicate what the...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Find three errors in the Java program below generated by the Java compiler. Indicate what the error is and which line number it is on, and explain how you would fix it: java.util.Scanner; 1234 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. import class AddEvens { 19. 20. 21. } public void main(String[] args) { } Scanner keyboard = new Scanner (System.input); System.out.print("Enter number: "); keyboard.nextInt (); int num = int sum= 0; for (int i=1, i <= num, i++) { if (i%2==0) { sum +=; System.out.println(i + " " + num + System.out.println("Sum of evens is " + sum); } } "+sum) ; Find three errors in the Java program below generated by the Java compiler. Indicate what the error is and which line number it is on, and explain how you would fix it: java.util.Scanner; 1234 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. import class AddEvens { 19. 20. 21. } public void main(String[] args) { } Scanner keyboard = new Scanner (System.input); System.out.print("Enter number: "); keyboard.nextInt (); int num = int sum= 0; for (int i=1, i <= num, i++) { if (i%2==0) { sum +=; System.out.println(i + " " + num + System.out.println("Sum of evens is " + sum); } } "+sum) ;
Expert Answer:
Answer rating: 100% (QA)
Here are three errors in the Java program and how to fix them Syntax error in class declaration Err... View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
Cannon Corporation had a net long-term capital gain of $50,000 and a net short-term capital loss of $75,000 in 2020. What are the tax consequences to Cannon as a result of its capital transactions?
-
The Taylor polynomial for sin(x) for a near 0 to order 5 is 1 1 sin(x) = x - + -x +0(x7) 6 120 The figure below shows a plot of sin(x) [blue] and the above Taylor polynomial [red]. 0.8 0.6 0.4 0.2 1...
-
One way to delete nodes from a known position in a leftist heap is to use a lazy strategy. To delete a node, merely mark it deleted. When a findMin or deleteMin is performed, there is a potential...
-
Selected information is available for Tim Hortons Inc. and Starbucks Corporation for a recent fiscal year: Instructions (a) Determine the missing amounts for [1] to [6]. (b) Which company has the...
-
What must be done to a functions equation so that its graph is reflected about the y-axis?
-
Match the measures of worth in the first column with one (or more) of the analysis approaches that is (are) appropriate for that measure. Measure of Worth (a) Annual Worth (b) External Rate of Return...
-
Samantha Montgomery (age 42) is employed by Canon Company and is paid a salary of $62,430. She has just decided to join the company's Simple Retirement Account (IRA form) and has a few questions....
-
Amazon, Inc. Presentation Your chief executive officer (CEO) has asked you to present the company's (Amazon, Inc.) process on making decisions under risks and uncertainty at the annual shareholders'...
-
As international purchases you have to pay 4 million dollars to your suppliers in USA in four months, The current exchange rate is IS = 10.5MAD. 1. What is the risk of this transaction? 2. How can...
-
Audrey Inc. manufactures dolls. During 2 0 2 3 , total costs incurred in making 1 0 , 0 0 0 dolls included $ 5 0 , 0 0 0 of fixed manufacturing overhead. The total absorption cost per doll was $ 3 0...
-
Scott is a mortgage broker and has to drive around often to see his clients. His employers has provided him with a car to use from 1 April 2 0 2 2 . The car was valued at $ 7 8 , 0 0 0 . Scott is...
-
a Queens auto dealer and beloved family man, became terminally ill in the summer of 2021. In preparation for his death, he began making arrangements for his estate by enlisting the legal services of...
-
Can you elucidate the intricacies of virtual memory management within modern operating systems, detailing the mechanisms employed to efficiently manage memory resources and facilitate seamless...
-
You've just borrowed $240,000 from the Never Ever Bank. In return, as a loan repayment, this bank requires that you and later all your future heirs pay back a fixed amount of money once a year...
-
Q2: a) Differentiate between annuity and compound interest. b) A father at the time of birth of his daughter decides to deposit a certain amount at the end of each year in the form of an annuity. He...
-
Show that gj concave AHUCQ Abadie For nonnegative variables, we have the following corollary.
-
Find all points on the paraboloid z = x2 + y2 (see Appendix D) where the tangent plane is parallel to the plane x + y + z = 1. Find equations of the corresponding tangent planes. Sketch the graphs of...
-
Suppose that f, g are nonnegative and locally integrable on [a, b) and that exists as an extended real number. a) Show that if 0 < L < and g is improperly integrable on [a, b), then so is f. b) Show...
-
Find the interval of convergence of each of the following power series. a) b) c) d) 0 log (-k- i (k+1)!
-
Because many consumers choose between coffee and tea, the coffee and tea demand functions depend on both prices. Suppose the demand curves for coffee and tea are where \(Q_{c}\) is the quantity of...
-
Governments use wage subsidies to maintain employment in times of economic recession, to encourage firms to hire and train specific groups of workers such as low-income workers, women, and students...
-
People who qualify for affordable housing in Sydney, Australia, have their rent capped at \(30 \%\) of their gross annual income. People who live in private rental properties in the city are not...
Study smarter with the SolutionInn App