Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java For this project, you will create a program that asks the user to enter a positive integer value less than 20. If the user

Java

For this project, you will create a program that asks the user to enter a positive integer value less than 20.

If the user enters a number greater than 20, the user should get an error.

If the user enters a number equal to or less than 20, display the double of each value beginning with 1 up to the selected number (multiply each number by 2), then provide the total of all doubles.

For example, if the user entered the number 5, the following should display:

Double up 1 = 2

Double up 2 = 4

Double up 3 = 6

Double up 4 = 8

Double up 5 = 10

Total = 30

You will be using mutator and accessor method. A mutator method is simply a fancy name for a method that modifies private data. An accessor method is a method which has the sole purpose of providing access to private data.

Minimum Requirements:

Create a class that has 3 methods.

1. A mutator method should take the number from the user and store it in a private variable. ()

2. Another method should perform the calculations, display the double up results and store the total in a private variable. This method must use a loop.

3. An accessor method should display the total.

Create a main method that creates an object of your class and calls each of the methods of the class.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle Autonomous Database In Enterprise Architecture

Authors: Bal Mukund Sharma, Krishnakumar KM, Rashmi Panda

1st Edition

1801072248, 978-1801072243

More Books

Students also viewed these Databases questions