Introduction: Arithmetic Expressions

Here are the prerequisites, learning objectives, and overview for this chapter.

We'll cover the following

Prerequisites

Objectives

After completing this chapter, you should be able to

  • Write a Java arithmetic expression that represents a given algebraic expression
  • Identify the data type of the value of a given arithmetic expression
  • Write a type cast and identify when one is necessary
  • Use the standard class Math to evaluate mathematical functions such as the square root and cosine

Overview

Imagine that we have been asked to write a Java program to evaluate some algebraic equations in support of a particular scientist’s research project. In the previous chapter, we saw some simple expressions that involved multiplication, addition, and subtraction. This chapter will discuss in depth how to write an arithmetic expression in Java. Such expressions are analogous to expressions in algebra. Both kinds of expressions contain operators, variables, constants, and parentheses.

Get hands-on with 1400+ tech skills courses.