1446T - TP2 - WEEK 4 - TugasPersonal ke-2 Minggu 4 Review...

Info icon This preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
TugasPersonal ke-2 Minggu 4 Review Questions: 1. Assume that int a=1 and double d=1.0, and that each expression is independent. What are the results of the following expressions? a. a = 46 / 9 b. a = 46 % 9 + 4 * 4 – 2 c. a = 45 + 43 % 5 * (23 * 3 % 2) d. a %= 3 / a + 3 e. a = 4 + d * d + 4 2. Evaluate the following method calls: a. Math.pow(2,2) b. Math.max(2, Math.min(3,4)) c. Math.round(2.5F) d. Math.ceil(-9.49) e. Math.floor(7.5) 3. Are the following two statements equivalent? Give your explanation! if (income <= 10000) Tax = income * 0.1; else if (income <= 20000) Tax = 1000 + (income – 10000) * 0.15; if (income <= 10000) Tax = income * 0.1; else if(income > 10000 && income <=20000) Tax = 1000 + (income – 10000) * 0.15; 4. What is wrong in the following code? if(score >= 60.0) Grade = ‘D’; else if(score >= 70.0) Grade = ‘C’; else if (score >= 80.0) Grade = ‘B’; else if(score >= 90.0) Grade = ‘A’; else
Image of page 1

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

View Full Document Right Arrow Icon
Grade = ‘F’; 5. Answer the following questions: a. Write a Boolean expression that evaluates to true if a number stored in variable num is between 1 and 100. b. Write a Boolean expression that evaluates to true if a number stored in variable num is between 1 and 100 or the number is negative. Programming Exercise: Please create a small program follow these criteria: 1. The program will show the menus, which are “Mathematic Test” for the first menu option and “Boolean Operator Test” for the second menu option.
Image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    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.

    Student Picture

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

  • Left Quote Icon

    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.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    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.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern