The user is assumed to enter the list in sorted order

Assignment Help JAVA Programming
Reference no: EM13166553

Write a program that will read in a list of positive integers (including zero) and display some statistics regarding the integers.

The user is assumed to enter the list in sorted order, starting with the smallest number and ending with the largest number.

Your program must store the all of the integers in an array. The maximum number of integers that you can expect is 100, however there may not necessarily be that many. Your program should allow the user to continue entering numbers until they enter a negative number or until the array is filled - whichever occurs first. If the user enters 100 numbers, you should output an message stating that the maximum size for the list has been reached, then proceed with the calculations.

After you have placed all of the integers into an array, your program should perform the following tasks, in this order:

  1. Display the count of how many numbers were read
  2. Display the smallest number in the array
  3. Display the largest number in the array
  4. Display the median (the median is the integer that is stored in the middle position of the array)
  5. Display the average of all the numbers
  6. Allow the user to search the array for a specified value.
    1. First, ask the user to enter an integer to search for.
    2. Next, search the array to determine if the given integer is in the array.
    3. If the integer is not found, display a message stating that the integer is not in the list.
    4. If the integer is found, then display the position number of where you found the integer. If the integer happens to be in the array more than once, then you only need to tell the first position number where you found it.
    5. After performing the search, ask the user if he/she wants to search for more integers. Continue searching for numbers until the user answers "N".

Technical notes and restrictions:

  • Remember that the keyboard object should be declared as a class variable (global).
  • Absolutely NO other global variables (class variables) are allowed (except for the keyboard object).
  • You are only allowed to use the number 100 one time in your program! You are not allowed to use the numbers 101, 99, 98, or any other number that is logically related to 100 anywhere in your program. If you need to make reference to the array size then, use the length variable to reference this rather than hard-coding numbers into your program.
  • You are required to write and use at least the following FOUR methods in this program:
    • A method to get the numbers from the user, and place them into an array. This method should return the number of integers that it actually retrieved. The array will be passed back through a parameter (remember that the method can make changes to an array's contents and the main program will automatically see the results).
    • A method to calculate, and return, the median of the array. This will be a double value.
      • If there are an odd number of integers in the array, then the median is defined as the integer stored in the middle array position.
      • If there are an even number number of integers in the array, then the median is defined as the average of the integers stored in the two middle array positions.
    • A method to calculate, and return, the average of the numbers in the array. This will be a double value.
    • A method to search for a specified value in the array. This method should return the first position number where the item is found, or return -1 if the item is not found.
  • The two calculating methods, and the searching method, should not get any values from the user, and should not print anything to the screen. The main program is responsible for all of the printing.
    The method which gets the numbers will need (of course) to get values from the user, but should not print anything to the screen.
  • Remember that at this stage, COMMENTING IS A REQUIREMENT! Make sure you FULLY comment your program. You must include comments that explain what sections of code is doing. Notice the key word "sections"! This means that you need not comment every line in your program. Write comments that describe a few lines of code rather than "over-commenting" your program.
  • You MUST write comments about every method that you create. Your comments must describe the purpose of the method, the purpose of every parameter the method needs, and the purpose of the return value (if the method has one).
  • Build incrementally. Don't tackle the entire program at once. Write a little section of the program, then test it AND get it working BEFORE you go any further. Once you know that this section works, then you can add a little more to your program. Stop and test the new code. Once you get it working, then add a little bit more.
  • Make sure you FULLY test your program! Make sure to run your program multiple times, inputting combinations of values that will test all possible conditions for your IF statements and loops. Also be sure to test border-line cases.

Reference no: EM13166553

Questions Cloud

Who is holding return real time big data analysis : Who is holding return realtime bigg data analyssis? what is the future of data big?
Add a draw() method to horse class. : Add a draw() method to your Horse class. You will also need to create a couple of Horses in your DrawPanel class, and call the draw() method for each Horse from the paintComponent() method. There is no need to modify the DrawPanelDriver class.
Major social factors in negotiation : What are the major social factors in negotiation? Who are the possible parties? How are they different, and how does this affect the negotiation?
Keep track of the size of the array : Keep track of the size of the array so that you cannot exceed the array boundaries. The implementation details (i.e. the private members)of your class are up to you, but the class should have the following public interface
The user is assumed to enter the list in sorted order : Make sure you FULLY test your program! Make sure to run your program multiple times, inputting combinations of values that will test all possible conditions for your IF statements and loops. Also be sure to test border-line cases.
Interaction between the customer and the machine : In Python:Simulate a cash register or ATM including the interaction between the customer and the machine (i.e. assume that you are automating the responses)
Effective parenting tricks : If you are a parent, describe one of your favorite and most effective parenting “tricks” and how it achieves its goal. If you are not a parent, describe how you might have seen another parent handle a troublesome child.
Rewrite this code in order to ask the user for input : rewrite this code in order to ask the user for input and then coverth it from infex to postfix ,, so i want to put a Scanner and this ask the user for input .. how to do it ?
Important in the environment of our organizations : Wellness programs are so important in the environment of our organizations, however, the problem is that there is no real cost savings up front and the savings are usually soft dollars - in other words, dollars that are not being spent but that are a..

Reviews

Write a Review

JAVA Programming Questions & Answers

  Develop a reservation system program for specific flights.

develop a reservation system program for specific flights. A customer should be able to select from one of four categories of seats on flights from RDU to any of at least three other destinations. Based on the user input of seat type and destination,..

  How many numbers do you want to enter

Write a program that asks the user "How many numbers do you want to enter?" With that value, create an array that is big enough to hold that amount of numbers (integers).

  Setting up the form page

Download and save the attached comment CGI mailer script form-mail2.pl to your server's cgi-bin directory, and change the permissions on the script to make it executable (not writable).

  Write a program that simulate n rolls of six-sided die

Write a program that simulate n rolls of six-sided die and displays the frequency of occurrence of each side and What is the most likely method signature of the "parseInt() - TNE60003

  Reads in up to 1000 non-negative integers

Write a program that reads in up to 1000 non-negative integers and displays distinct numbers (i.e., if a number appears multiple times, it is displayed only once). (Hint: Read each number and store it in an array if it is new. If the number is alread..

  Write java program which will permit user to make selection

Write the Java Program which will permit the user to make selection. You will present user with two options to perform, then you will perform action selected by user.

  Write a program in java that reads contents of two vectors

Write a program in Java that reads contents of two vectors, and then displays the sum of these two vectors. The program should prompt the user to enter the size of the vectors first.

  Write java program to find calories-conditional operator

Write down the answer for this program? Write down Java program (use Conditional (? Operator) which suggests number of calories a person must eat each day.

  Implement/update specific methods for the dfs of a graph

implement/update specific methods for the DFS of a graph; for at least 2 graphs (1 being the provided one), show the DFS order of vertices in the graph, and for each node,

  Describe principles of data abstraction and inheritance

Study the principles of data abstraction, inheritance and dynamic binding. Use Library to get started on finding resources.You must take the terms and describe it.

  Make a fourth button called special

Make a fourth button called "special" that does something else notdescribed in the assignment, such as change the background color.

  Write a program that asks a user for a file name and prints

Write a program that asks a user for a file name and prints the number of characters, words, and lines in that file.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd