1. The following program has many syntax errors: public class Programl { This method should...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
1. The following program has many syntax errors: public class Programl { • This method should take an integer x and return: 2x when x is odd 4 the unchanged value of x when x is even * */ public int double_if_odd(x) { { if x % 2 = 1: } return x public void main(String[]) scan Scanner(System.in); print('Enter an integer x: '); integer x scan.next() print("double_if_odd(x) ", double_if_odd(x)) Determine and fix all of the problems with this program so that it will compile and do the following when run: • Ask the user to enter an integer and store the user's input in the variable x. • Call the method double_if_odd with x as its input, and print the value returned by that method, double_if_odd should have the functionality specified in the comment that precedes it. 1. The following program has many syntax errors: public class Programl { • This method should take an integer x and return: 2x when x is odd 4 the unchanged value of x when x is even * */ public int double_if_odd(x) { { if x % 2 = 1: } return x public void main(String[]) scan Scanner(System.in); print('Enter an integer x: '); integer x scan.next() print("double_if_odd(x) ", double_if_odd(x)) Determine and fix all of the problems with this program so that it will compile and do the following when run: • Ask the user to enter an integer and store the user's input in the variable x. • Call the method double_if_odd with x as its input, and print the value returned by that method, double_if_odd should have the functionality specified in the comment that precedes it.
Expert Answer:
Related Book For
Posted Date:
Students also viewed these programming questions
-
IN-CLASS TASK Mr. W. is a 63-year-old recently retired engineer with a history of irritable bowel syndrome that causes frequent diarrhea and rectal bleeding. His wife is a schoolteacher. In...
-
It is the post-apocalyptic era, and hardship and depression run rampant. You are currently at the bottom of a staircase in the basement of an abandoned building looking at what is pure...
-
This assignment reviews object-oriented programming concepts such as classes, methods, constructors, accessor methods, and access modifiers. It makes use of an array of objects as a class data...
-
Pohle Designs has a department that makes high-quality leather cases for iPads. Consider the following data for a recent month: Budget Formula per Unit Various Levels of Output 10.000 1.000 12000...
-
Write the whole number in each sentence in standard form. 1. The average distance between the surfaces of the Earth and the Moon is about two hundred thirty four thousand miles. 2. The world's...
-
Yang Corporation wholesales repair products to equipment manufacturers. On May 1, 2014, Yang Corporation issued $20,000,000 of 10-year, 9% bonds at a market (effective) interest rate of 7%, receiving...
-
Describe the key elements of a customer care programme that would be appropriate in a manufacturing or service environment with which you are familiar.
-
Goldstein Inc. manufactures and sells plastic boxes and trays. Sales are projected to be evenly spread over the annual period. Estimated product sales and material needs for each unit of product...
-
The following data, expressed as $10 4 , are the closed ledger accounts showing assets, liabilities, income, and expenses of Blue River Fabricators, Inc., a family owned firm that does not declare...
-
1. Considering Yips globalisation framework (Figure 9.2), what drivers of internationalisation do you think were most important when Wanda entered the US market through its AMC and Legendary...
-
Remember, being an effective, successful business leader doesn't always require your sharing good news, such as the record profits you made, the rapid growth you're experiencing, or the many benefits...
-
Apple tests each of its manufactured iPhones and labels each as acceptable or defective. Determine whether the data described are qualitative or quantitative and give their level of measurement. If...
-
Write a brief description of some ways in which you think that the science of statistics can be used in your major field of study. (If you have not yet selected a major, answer the question for a...
-
What is the margin of error in a statistical study, and why is it important? Does It make Sense?
-
Choose a sport and describe at least three different statistics commonly tracked by participants in or spectators of the sport. In each case, briefly describe the importance of the statistic to the...
-
Find a recent news report about a statistical study whose results you believe are meaningful and important. In one page or less, summarize the study and explain why you find it believable.
-
h) I proceed to study the short-run dynamic of the changes in gold price (LGPRICE) and inflation (INF) and estimated a VAR model. Write down the VAR(1) model using the notation LGPRICE and INF? (j)...
-
CLASS PERIO Solving Linear Equations: Variable on Both Sides Solve each equation. 1) 6r+ 7 = 13 + 7r 3) -7x-3x+2=-8x-8 5)-14 +66+7-26=1+5b 7) n-3n = 14-4n 2) 13-4x=1-x 4)-8-x= x - 4x 6)n+2=-14-n 8)...
-
Redo Listing 9.9, replacing the character array with a string object. The program should no longer have to check whether the input string fits, and it can compare the input string to "" to check for...
-
The Kingdom of Neutronia, where the unit of currency is the tvarp, has the following income tax code: First 5,000 tvarps: 0% tax Next 10,000 tvarps: 10% tax Next 20,000 tvarps: 15% tax Tvarps after...
-
Write a program that uses an array of char and a loop to read one word at a time until the word done is entered.The program should then report the number of words entered (not counting done).A sample...
-
A rotary drum filter has a diameter of $6 \mathrm{ft}$ and a length of $8 \mathrm{ft}$ and rotates at a rate of $30 \mathrm{~s} / \mathrm{cycle}$. The filter operates at a vacuum of $500 \mathrm{~mm}...
-
You must filter $1000 \mathrm{lb}_{\mathrm{m}} / \mathrm{min}$ of an aqueous slurry containing $40 %$ solids by weight using a rotary drum filter with a diameter of $4 \mathrm{~m}$ and a length of $4...
-
A slurry containing $1 \mathrm{lb}_{\mathrm{m}}$ of solids per gallon of water is to be filtered in a plate-and-frame filter having a total filtering area of $60 \mathrm{ft}^{2}$. The slurry is fed...
Study smarter with the SolutionInn App