Question: Java Object Oriented Programming Creating and Using Methods in Classes ---------------------------------------------------------------------------------------------------- Write a Java application (with a main() method), and an additional class called Calculator.
Java Object Oriented Programming
Creating and Using Methods in Classes
----------------------------------------------------------------------------------------------------
Write a Java application (with a main() method), and an additional class called Calculator. The Calculator class will be an engine with many methods (some overloaded from others) to perform various arithmetic and calculating tasks. You can instantiate one object in main() to perform all of the functions by calling for example:
Calculator calcEngine = new Calculator();
Then, subsequently call calcEngine.table(10,10), calcEngine.table(3.0,2), calcEngine.primes(), etc. as the task to perform from the menu selection in a switch() statement.
Alternatively, you can put main() into the class, but a separate application class with main() is recommended. All methods you create should be lowercase, except the constructors.
The Calculator class will:
1. Have necessary constructor methods, in addition to the default constructor (0 argument constructor). The constructor is a function (method) which allocates memory and initialized the member variables specified in (a.).
2. Encapsulate data members (member variables) as needed.
3. Include getters/setters for to serve as as mutators and accessors as needed for each variable.
4. Create the following member methods for the class:
a. A Multiplication Table Generator method called void table(int, int) which takes as parameters, rows and columns, nicely formatted with headings, using printf().
b. Overload the void table(double, int) function and create An Exponentiation Table Generator which takes as parameters, rows and columns (which would be base and exponent).
c. The table() function will need to call functions which you create called string multiply(n, n) or string power(n, e)
d. A member method called void primes(void) which generates the first 10 prime numbers, nicely formatted using printf().
e. An overload of primes called void primes(double) which accepts a value gotten from main() (up to 50) and generates that number of primes, nicely formatted.
f. A method called void circle(void) which prompts the user and displays the area and circumference of a circle, given the radius.
g. A method called stats() which prompts the user to enter 10 values and displays the mean and sum of the values.
h. An overload of void stats() which generates 10 random numbers and displays the mean and sum of the values.
i. A method called ascii() which takes the start and end values validated in main() and generates a table with the following columns:
Character Int Value Octal Value Hexadecimal Value Binary Value
The asci() method will call a method you create called binary() to generate a binary number from the ASCII code.
j. A void conversion() method which will prompt the user and convert inputted values, per your preference from a list of options including volume (CI to CC), length (feet to meters), weight (lbs to kg), temperature (F to C).
The Java application class (with a main method) will:
a. Create a menu of options for the user as such:
Welcome to the Calculator Program!
1. Create Multiplication Table (up to 10x10).
2. Create Exponentiation Table (up to 5x5).
3. Show the first 10 prime numbers.
4. Show a list of prime numbers (up to 50).
5. Find the area and circumference of a circle (provide diameter).
6. Generate statistics for a list of inputted values (up to 10), including mean, and sum.
7. Generate statistics for a list of random values (up to 10), including mean, and sum.
8. Generate a table showing ASCII values for a range (validated between 32 and 126).
9. Conversion of Fahrenheit to Celsius:
Please enter your selection:
Required Output: Generate output samples demonstrating all of your member functions, adequately testing them and showing their functionality (i.e. inputting values, outputting values (displaying them), performing calculations, etc.).
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
