1. (5 pts) Given an integer array: int A[] = new int[10]; It is easy to...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
1. (5 pts) Given an integer array: int A[] = new int[10]; It is easy to print values of array elements from the first one to the last one by using a for loop. Can you use a for loop to print those values from the LAST array element to the FIRST array element? (i.e. print values in the reversed order). 2. (2pts) What is a recursive method? 3. (2pts) What are important factors when designing a recursive method? 4. (2pts) is the following method recursive method? If it is, are there any design flaws? What are those flaws? public static void ABC(int x) { System.out.println(x); } ABC(x); 5. (4 pts) Finish the method below. It converts a Celsius temperature (which is passed as a method parameter "celsius") to a Fahrenheit temperature. The method returns the Fahrenheit result in floating point number. The conversion formula is: F = (9.0/5.0) X C + 32 public static } cToF(double celsius) { 6. Review our course example Dice.java (in Week13&14 folder) and answer the following questions. 6.1. (2pts) Have we defined any member variables in the Dice class? If yes, what are they? 6.2. (2pts) What modifiers we used to define those variables? (public? private?) Why we use that specific modifier? 6.3. (2pts) Have we defined any member methods in the Dice class? If yes, what are they? 6.4. (2pts) How would you call those methods? Please write down a piece of code. 7. (10 pts) Read code parts below and answer the questions. Each code part is independent. 7.1) public static int X(int a[]) { int sum = 0; for(int w = 0; w 7.4) 7.5) public static void printx(int i) { if(i 8. Read the code below and answer the questions (4 pts): public class Counter { private static int count = 0; private int self; public Counter() { ++count; self = 0; } public Counter(int i) { ++count; self = i; } public void addMe(int i) { self = self + i; } public void runMe() { System.out.println("the System.out.println("the } } public static void main(String[] args) { Counter a = new Counter(); Counter b = new Counter(100); a.addMe(3); b.addMe(5); value of count is " + count); value of self is "+self); a.runMe(); b.runMe(); } 8.1) What is the different between member variable count and self? 8.2) What will be printed when the program is executed? 9. The code part below tries to define an Employee class. Obviously, class Employee provides ways to set/get names, SSN, and salary. Please fill out the blanks below. (The comment at the end of each blank line indicates the expected behavior the line should have. There is only one statement at each blank line) (12 pts). Note: there are 6 blanks in this question. public class Employee { private String firstName; private String lastName; private String social; private double monthlySalary; public Employee(String first, String last, String ssn) { firstName = first; lastName = last; } public void setFirstName(String first) { firstName = first; } public void setLastName(String last) { } public String getName() { } monthlySalary = 0; } // blank1: setup SSN } public void setSSN(String ssn) { public String getSSN() { // blank2: setup last name return (firstName + " " + lastName); // blank3: setup SSN // blank4: get SSN } public void setSalary(double x) { } public double getSalary() { } // blank5: setup salary // blank6: get salary 1. (5 pts) Given an integer array: int A[] = new int[10]; It is easy to print values of array elements from the first one to the last one by using a for loop. Can you use a for loop to print those values from the LAST array element to the FIRST array element? (i.e. print values in the reversed order). 2. (2pts) What is a recursive method? 3. (2pts) What are important factors when designing a recursive method? 4. (2pts) is the following method recursive method? If it is, are there any design flaws? What are those flaws? public static void ABC(int x) { System.out.println(x); } ABC(x); 1. (5 pts) Given an integer array: int A[] = new int[10]; It is easy to print values of array elements from the first one to the last one by using a for loop. Can you use a for loop to print those values from the LAST array element to the FIRST array element? (i.e. print values in the reversed order). 2. (2pts) What is a recursive method? 3. (2pts) What are important factors when designing a recursive method? 4. (2pts) is the following method recursive method? If it is, are there any design flaws? What are those flaws? public static void ABC(int x) { System.out.println(x); } ABC(x); 1. (5 pts) Given an integer array: int A[] = new int[10]; It is easy to print values of array elements from the first one to the last one by using a for loop. Can you use a for loop to print those values from the LAST array element to the FIRST array element? (i.e. print values in the reversed order). 2. (2pts) What is a recursive method? 3. (2pts) What are important factors when designing a recursive method? 4. (2pts) is the following method recursive method? If it is, are there any design flaws? What are those flaws? public static void ABC(int x) { System.out.println(x); } ABC(x); 5. (4 pts) Finish the method below. It converts a Celsius temperature (which is passed as a method parameter "celsius") to a Fahrenheit temperature. The method returns the Fahrenheit result in floating point number. The conversion formula is: F = (9.0/5.0) X C + 32 public static } cToF(double celsius) { 6. Review our course example Dice.java (in Week13&14 folder) and answer the following questions. 6.1. (2pts) Have we defined any member variables in the Dice class? If yes, what are they? 6.2. (2pts) What modifiers we used to define those variables? (public? private?) Why we use that specific modifier? 6.3. (2pts) Have we defined any member methods in the Dice class? If yes, what are they? 6.4. (2pts) How would you call those methods? Please write down a piece of code. 5. (4 pts) Finish the method below. It converts a Celsius temperature (which is passed as a method parameter "celsius") to a Fahrenheit temperature. The method returns the Fahrenheit result in floating point number. The conversion formula is: F = (9.0/5.0) X C + 32 public static } cToF(double celsius) { 6. Review our course example Dice.java (in Week13&14 folder) and answer the following questions. 6.1. (2pts) Have we defined any member variables in the Dice class? If yes, what are they? 6.2. (2pts) What modifiers we used to define those variables? (public? private?) Why we use that specific modifier? 6.3. (2pts) Have we defined any member methods in the Dice class? If yes, what are they? 6.4. (2pts) How would you call those methods? Please write down a piece of code. 5. (4 pts) Finish the method below. It converts a Celsius temperature (which is passed as a method parameter "celsius") to a Fahrenheit temperature. The method returns the Fahrenheit result in floating point number. The conversion formula is: F = (9.0/5.0) X C + 32 public static } cToF(double celsius) { 6. Review our course example Dice.java (in Week13&14 folder) and answer the following questions. 6.1. (2pts) Have we defined any member variables in the Dice class? If yes, what are they? 6.2. (2pts) What modifiers we used to define those variables? (public? private?) Why we use that specific modifier? 6.3. (2pts) Have we defined any member methods in the Dice class? If yes, what are they? 6.4. (2pts) How would you call those methods? Please write down a piece of code. 7. (10 pts) Read code parts below and answer the questions. Each code part is independent. 7.1) public static int X(int a[]) { int sum = 0; for(int w = 0; w 7. (10 pts) Read code parts below and answer the questions. Each code part is independent. 7.1) public static int X(int a[]) { int sum = 0; for(int w = 0; w 7. (10 pts) Read code parts below and answer the questions. Each code part is independent. 7.1) public static int X(int a[]) { int sum = 0; for(int w = 0; w 7.4) 7.5) public static void printx(int i) { if(i 7.4) 7.5) public static void printx(int i) { if(i 7.4) 7.5) public static void printx(int i) { if(i 8. Read the code below and answer the questions (4 pts): public class Counter { private static int count = 0; private int self; public Counter() { ++count; self = 0; } public Counter(int i) { ++count; self = i; } public void addMe(int i) { self = self + i; } public void runMe() { System.out.println("the System.out.println("the } } public static void main(String[] args) { Counter a = new Counter(); Counter b = new Counter(100); a.addMe(3); b.addMe(5); value of count is " + count); value of self is "+self); a.runMe(); b.runMe(); } 8.1) What is the different between member variable count and self? 8.2) What will be printed when the program is executed? 8. Read the code below and answer the questions (4 pts): public class Counter { private static int count = 0; private int self; public Counter() { ++count; self = 0; } public Counter(int i) { ++count; self = i; } public void addMe(int i) { self = self + i; } public void runMe() { System.out.println("the System.out.println("the } } public static void main(String[] args) { Counter a = new Counter(); Counter b = new Counter(100); a.addMe(3); b.addMe(5); value of count is " + count); value of self is "+self); a.runMe(); b.runMe(); } 8.1) What is the different between member variable count and self? 8.2) What will be printed when the program is executed? 8. Read the code below and answer the questions (4 pts): public class Counter { private static int count = 0; private int self; public Counter() { ++count; self = 0; } public Counter(int i) { ++count; self = i; } public void addMe(int i) { self = self + i; } public void runMe() { System.out.println("the System.out.println("the } } public static void main(String[] args) { Counter a = new Counter(); Counter b = new Counter(100); a.addMe(3); b.addMe(5); value of count is " + count); value of self is "+self); a.runMe(); b.runMe(); } 8.1) What is the different between member variable count and self? 8.2) What will be printed when the program is executed? 9. The code part below tries to define an Employee class. Obviously, class Employee provides ways to set/get names, SSN, and salary. Please fill out the blanks below. (The comment at the end of each blank line indicates the expected behavior the line should have. There is only one statement at each blank line) (12 pts). Note: there are 6 blanks in this question. public class Employee { private String firstName; private String lastName; private String social; private double monthlySalary; public Employee(String first, String last, String ssn) { firstName = first; lastName = last; } public void setFirstName(String first) { firstName = first; } public void setLastName(String last) { } public String getName() { } monthlySalary = 0; } // blank1: setup SSN } public void setSSN(String ssn) { public String getSSN() { // blank2: setup last name return (firstName + " " + lastName); // blank3: setup SSN // blank4: get SSN 9. The code part below tries to define an Employee class. Obviously, class Employee provides ways to set/get names, SSN, and salary. Please fill out the blanks below. (The comment at the end of each blank line indicates the expected behavior the line should have. There is only one statement at each blank line) (12 pts). Note: there are 6 blanks in this question. public class Employee { private String firstName; private String lastName; private String social; private double monthlySalary; public Employee(String first, String last, String ssn) { firstName = first; lastName = last; } public void setFirstName(String first) { firstName = first; } public void setLastName(String last) { } public String getName() { } monthlySalary = 0; } // blank1: setup SSN } public void setSSN(String ssn) { public String getSSN() { // blank2: setup last name return (firstName + " " + lastName); // blank3: setup SSN // blank4: get SSN 9. The code part below tries to define an Employee class. Obviously, class Employee provides ways to set/get names, SSN, and salary. Please fill out the blanks below. (The comment at the end of each blank line indicates the expected behavior the line should have. There is only one statement at each blank line) (12 pts). Note: there are 6 blanks in this question. public class Employee { private String firstName; private String lastName; private String social; private double monthlySalary; public Employee(String first, String last, String ssn) { firstName = first; lastName = last; } public void setFirstName(String first) { firstName = first; } public void setLastName(String last) { } public String getName() { } monthlySalary = 0; } // blank1: setup SSN } public void setSSN(String ssn) { public String getSSN() { // blank2: setup last name return (firstName + " " + lastName); // blank3: setup SSN // blank4: get SSN } public void setSalary(double x) { } public double getSalary() { } // blank5: setup salary // blank6: get salary } public void setSalary(double x) { } public double getSalary() { } // blank5: setup salary // blank6: get salary } public void setSalary(double x) { } public double getSalary() { } // blank5: setup salary // blank6: get salary
Expert Answer:
Related Book For
Financial Accounting and Reporting a Global Perspective
ISBN: 978-1408076866
4th edition
Authors: Michel Lebas, Herve Stolowy, Yuan Ding
Posted Date:
Students also viewed these programming questions
-
can someone solve this Modern workstations typically have memory systems that incorporate two or three levels of caching. Explain why they are designed like this. [4 marks] In order to investigate...
-
answer the question clearly You are building a flight-control system for which a convincing safety case must be made. Would you assign the tasks of safety requirements engineering, test case...
-
Heights Academy, a private school, serves 500 students: 200 in the middle school (Grades 6 to 8) and 300 in the high school (Grades 9 to 12). Each school group has its own assistant principal, and...
-
Adams Moving and Storage, a family-owned corporation, declared a property dividend of 1,000 shares of GE common stock that Adams had purchased in February for $37,000 as an investment. GE's shares...
-
The treasurer for Pittsburgh Iron Works wishes to use financial futures to hedge her interest rate exposure. She will sell five Treasury futures contracts at $123,000 per contract. It is July and the...
-
In Exercises 9 and 10, use the given set of points to a. Compute b0 and b1. b. Compute the predicted value y for the given value of x. c. Compute the residual standard deviation se. d. Compute the...
-
On January 1, 20X1, Wade Crimbring, Inc., a dealer in used manufacturing equipment, sold a CNC milling machine to Fletcher Bros., a new business that plans to fabricate utility trailers. To conserve...
-
The following data has been provided by Lee Company regarding its inventory purchases and sales throughout the year. Transaction Units Cost per Unit January 1 Balance 185 $86 March 14 Sale 54 May 23...
-
The logic of pumping lemma is an example of the pigeon - hole principle. True or False? True False
-
Equipment has a debit side in a trial balance, why here they are in credit side?
-
On 1 January 2019, Nest plc issued 100,000 1 6% convertible redeemable preference shares, incurring issue costs of 6,700. The preference shares are redeemable at par for cash on 31 December 2023 or...
-
Investigate the facts and identify the issues. Collect the appropriate authorities. Analyze the research. Develop the reasoning and conclusion. Communicate the results. This week you will have an...
-
What report will display the individual invoices issued and receipts posted for a specific customer?
-
Elaborate on the core business model and how it has transformed under time and cost pressures?
-
7. Problem 3.6. The comparison calorimeter is used to determine the specific heat of milk. The first cup is filled with 100g of distilled water having a specific heat of 4.18 kJ/kg K. The other cup...
-
Portal Manufacturing has total fixed costs of $520,000. A unit of product sells for $15 and variable costs per unit are $11. a). Prepare a contribution margin income statement showing predicted net...
-
Haeffner PLC is an accounting firm. Some of its clients face the following situations. For each, it is assumed that a reliable estimate can be made of any outflows expected: 1. On 9 December X1 the...
-
Multiple Choice Questions 1. In a capital increase, the difference between the price paid by the buyer for a companys common share and the par value of each share can be called (several possible...
-
In the following list of qualitative characteristics of an accounting signal, choose the two that seem to you to be the most important ones (Explain your choice): (a) Verifiable (b) Fair and true (c)...
-
A simplified vibration analysis of an airplane considers bounce and pitch motions (Fig. 6.24(a)). For this, a model consisting of a rigid bar (corresponding to the body of the airplane) supported on...
-
Derive the equations of motion, using Newton's second law of motion, for each of the systems shown in Figs. 6.21. Pulley, mass M, mass moment of inertia Jo 3r 3m T x(1) F(t) 2k 000 T x2(1) m T X3(1)...
-
Derive the equations of motion, using Newton's second law of motion, for each of the systems shown in Figs. 6.22. M, cos wt G 15 G3 13 ka 03 4 kn 12 G k3 16 G6 G Number of teeth on gear G, n, (i = 1...
Study smarter with the SolutionInn App