Chapter 8 Java Assignment

Create a folder named Chapter 08 Program and use it to create a Java program to do the following:

 

Console

 

Welcome to the Squares and Cubes table

Enter an integer: five

Error! Invalid integer. Try again.

Enter an integer: -5

Error! Number must be greater than 0

Enter an integer: 101

Error! Number must be less than or equal to 100

Enter an integer: 9

 

Number  Squared Cubed

======  ======= =====

1       1       1

2       4       8

3       9       27

4       16      64

5       25      125

6       36      216

7       49      343

8       64      512

9       81      729

 

Continue? (y/n): y

 

Enter an integer: 3

 

Number  Squared Cubed

======  ======= =====

1       1       1

2       4       8

3       9       27

 

Continue? (y/n): n

 

Operation

 The application prompts the user to enter an integer.

The application displays a table of squares and cubes from 1 to the value entered by the user.

The application prompts the user to continue

 

Specification

The formulas for calculating squares and cubes are:

    square = x * x

    cube = x * x * x

Assume that the user will enter a valid integer.

The application should continue only if the user enters “y” or “Y” to continue.

 

Validation

Be sure the value entered is an integer and that it is greater than 0 and no more than 100.

Need a custom answer at your budget?

This assignment has been answered 2 times in private sessions.

© 2024 Codify Tutor. All rights reserved