EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
9th Edition
ISBN: 9781337671385
Author: FARRELL
Publisher: CENGAGE LEARNING - CONSIGNMENT
bartleby

Videos

Question
Book Icon
Chapter 2, Problem 1PE

a. Evaluate the expression, 4 + 6 * 2

Program Plan Intro

Operator Precedence:

An expression is a statement, which will hold a value when it is evaluated. A mathematical expression will hold multiple operators and grouping symbols; an expression will be evaluated based on the precedence of the operator. The rules of the operator precedence are given below.

  • Unary negation (-) and brackets () will have the highest priority.
  • Multiplication (*), division (/) and modulus (%) will have the next highest priority.
  • Addition (+), subtraction (-) will have the lowest priority.

b. Evaluate the expression, 10 / 5 + 8

Explanation of Solution

In the above expression, the division “/” operation will be evaluated first and next “+” addition operation will be executed as shown below:

St...

c. Evaluate the expression, 12 / 4 + 16 / 2

Explanation of Solution

In the above expression, the division “/” operation will be evaluated first and next “+” addition operation will be executed as shown below:

Step 1:

 �...

d. Evaluate the expression, 17 / 2

Explanation of Solution

In the above expression, the division “/” operation will be evaluated first and the quotient is returned as the result as shown b...

e. Evaluate the expression, 22 / 5

Explanation of Solution

In the above expression, the division “/” operation will be evaluated first and the quotient is returned as the result as shown b...

f. Evaluate the expression, 39 / 10

Explanation of Solution

In the above expression, the division “/” operation will be evaluated first and the quotient is returned as the result as shown be...

g. Evaluate the expression, 19 % (2 + 3)

Explanation of Solution

In the above expression, the values inside the brackets are evaluated first and then modulus (%) operator is evaluated and the remainder is returned as a result as shown below:

...

h. Evaluate the expression, 3 + 4 * 20 / 3

Explanation of Solution

In the above expression, the multiplication “*” operation will be evaluated first, next division “/” operation is evaluated and at last, addition “+”operation will be evaluated as shown below:

...

i. Evaluate the expression, 36 % (6 + 2)

Explanation of Solution

In the above expression, the values inside the brackets are evaluated first and then modulus (%) operator is evaluated and the remainder is returned as a result as shown below:

...

j. Evaluate the expression, 8 % 2 * 0

Explanation of Solution

In the above expression, the values inside the brackets are evaluated first and then modulus (%) operator is evaluated and the remainder is returned as a result as shown below:

...

Blurred answer
Students have asked these similar questions
Write a Java regular expression for each of the following: a. Phone numbers, such as (609) 555-1234 b. Social Security numbers, such as 123-45-6789 c. Dates, such as December 31, 1999
in java: Write a program that reads the following information and prints a payroll statement: Employee’s name (e.g., Smith) Number of hours worked in a week (e.g., 10) Hourly pay rate (e.g., 9.75) Federal tax withholding rate (e.g., 20%) State tax withholding rate (e.g., 9%) Your program must use proper formatting  for the output either by using the printf command or String.format
• FormulaEvaluator.java Requirements: Evaluate the following expression for any value of the variable x, and save the result in a variable of the type double. You must use the abs(), pow(), and sqrt() methods of the Math class to perform the calculation. You may use a single assignment statement with a somewhat large expression, or you may break the expression into multiple assignment statements. The latter may be easier to debug if you are not getting the correct result. 5x +3} ( √8x* — 6x²³ + 4x² + |20x+1) (9x³+7x² +5x+3) Next, determine the number of digits to the left and to the right of the decimal point in the result. [Hint: You can convert the double variable into a String variable using the static method Double.toString(result). Then, on this String variable use the indexOf() method from the String class to find the position of the decimal point (".") and use the length() method to find the length. Knowing the location of the decimal point and the length of the String, you…
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
  • Text book image
    EBK JAVA PROGRAMMING
    Computer Science
    ISBN:9781337671385
    Author:FARRELL
    Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Files & File Systems: Crash Course Computer Science #20; Author: CrashCourse;https://www.youtube.com/watch?v=KN8YgJnShPM;License: Standard YouTube License, CC-BY
UNIX Programming (Part - 10) The File System (Directories and Files Names); Author: ITUTEES;https://www.youtube.com/watch?v=K35faWBhzrw;License: Standard Youtube License