Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need the code in java. AND PLEASE SOLVE IT AS SOON AS POSSIBLE PROGRAM 1: Write a program with an array that is initialized

I need the code in java. AND PLEASE SOLVE IT AS SOON AS POSSIBLE

PROGRAM 1:

Write a program with an array that is initialized with following test data:

45, 30, 79, 01, 4, 99, 49, 21, 51, 77, 5, 45, 89, 67, 43, 24, 90, 29

Use any primitive data type of your choice for the array. The program should also have the following methods:

getTotal. This method should accept the above array as its argument and return the sum of the values in the array.

getAverage. This method should accept the above array as its argument and return the average of the values in the array.

getHighest. This method should accept the above array as its argument and return the highest value in the array.

getLowest. This method should accept the above array as its argument and return the lowest value in the array.

Demonstrate each of the methods in the program and the program should display the Sum, Average, Highest and the Lowest value.

PROGRAM 2:

Write a class that has three overloaded static methods for calculating the areas of the following geometric shapes:

circles rectangles cylinders

Here are the formulas for calculating the area of the shapes:

Area of circle:

Area of a rectangle: Area = Length * Width

Area of a cylinder: Area

Note: The above formula for the area of the cylinder is actually the volume of the cylinder but our program, call it area.

For PI () use the PI field in Math class.

For circle area: Use 10 for radius.

For rectangle area: Use 20 for length and 15 for width.

For cylinder area: Use 10 for radius and 5 for height.

Because the three methods are to be overloaded, they should each have the same name, but different parameter list. Demonstrate the class in a complete program.

Submit two files, one containing the methods and other containing the driver.

PROGRAM 3:

Create a class containing the main method and ask the user to enter a string. Write another method that accepts a reference to the String object as an argument and returns true if the argument ends with ".com" or ".net". or ".gov". Otherwise, the method should return false and display the returned value. Return true or false using a boolean variable.

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

Learning PostgreSQL

Authors: Salahaldin Juba, Achim Vannahme, Andrey Volkov

1st Edition

178398919X, 9781783989195

More Books

Students also viewed these Databases questions

Question

=+applying to all or most employers and employees?

Answered: 1 week ago

Question

=+associated with political parties and if so, which ones? Are

Answered: 1 week ago