{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

# Lecture20 - Java Programming 3e Concepts and Techniques...

This preview shows pages 1–10. Sign up to view the full content.

Java Programming, 3e Concepts and Techniques Chapter 5 Arrays, Loops, and Layout Managers Using External Classes (II) ICTN 2730 Lecture 20 02/27/2008

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Chapter 4: Decision Making and Repetition with Reusable Objects 2 Assignments Read chapter 5 and lecture notes. Homework 5 sample solutions have been posted. Homework 6 is due tonight. Make sure you understand Homework 5 before doing Homework 6. Consider completing the bonus section if you would like to improve the final grade.
Chapter 4: Decision Making and Repetition with Reusable Objects 3 Quiz 02 Evaluate the following expression: 2*7/3+4+Math.pow(5,2) 33.0 (Correct answer) 33 33.66 33.7 Check pages 16-18 in lecture18.ppt. We need to learn from the homework. Please check the sample solutions.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Chapter 4: Decision Making and Repetition with Reusable Objects 4 Quiz 02 2*7/3 = 4 The remainder is dropped. Check Integer Division on Page 151. Math.pow(5,2) = 25.0 //Double value 2*7/3+4+Math.pow(5,2) = 4+4+ 25.0 = 33.0 //Result is double, 33.0 != 33 When int values are mixed with double values in an expression, Java stores the answer as the larger data type (double). Declare the data type of the result as int will result in an error “possible loss of precision”. Why do we care?
Chapter 4: Decision Making and Repetition with Reusable Objects 5 Quiz 02 int a=7; int b=10; boolean c=(a<b)||(a==b); What is the value of c? (a < b)==true (a==b)==false true || false == true The value of c is true Check page 236 for logical operators

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Chapter 4: Decision Making and Repetition with Reusable Objects 6 Quiz 02 public float TaxWithheld(float income, float withheldRate) { float withheld; withheld=income*withheldRate; return withheld; } The variable income is a parameter .
Chapter 4: Decision Making and Repetition with Reusable Objects 7 Quiz 02 System.out.println("It"+"is"+"a"+"good"+"d ay!"); What will the output look like? Itisagoodday! (Correct answer) It is a good day! (Wrong) How to join strings, numbers using the plus sign?

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Chapter 4: Decision Making and Repetition with Reusable Objects 8 Quiz 02 public float TaxWithheld(float income , float withheldRate) { float withheld; withheld=income*withheldRate; return withheld; } In the main method, the TaxWithheld() method above is called by the following statement: result=TaxWithheld( salary , rate); //call method What is the data type of salary? Answer: float What is the return type of the method? Answer: float Arguments and parameters for a called method and the calling statement must be of the same number, order, and data type
Chapter 4: Decision Making and Repetition with Reusable Objects 9 Quiz 02 Which of the following statements can be used to display text in an applet?

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern