- Home
- Arithmetic operators
- Calculate values of a function

Monday, November 13, 2023
⁃
Difficulty:
Intermediate

Create a program Java to display certain values of the function *y= x2 - 2x + 1*. Ask the user for the range of integers *x* to show the function.

- Ask the user for the range of integer numbers x.
- Calculate the values of the function (y= x2 - 2x + 1) for each x in the range.
- Display the results of the function for each x.

-10 10

121 100 81 64 49 36 25 16 9 4 1 0 1 4 9 16 25 36 49 64 81

Share it on your social media and challenge your friends to solve programming problems. Together, we can learn and grow.

The code has been successfully copied to the clipboard.

Continue improving your Java programming skills with our selection of practical exercises from the lesson. Click on Practice and challenge your knowledge!

Practice with easy and intermediate Java exercises on arithmetic operations and some types of numerical data.