Write a program that reads from keyboard a sequence

Assignment Help JAVA Programming
Reference no: EM131323849

Assignment

In this assignment, you are required to specify and implement a Java

The language is Java. In this assignment, you are required to specify and implement a Java class named IntSortedList. The instances of IntSortedList are sorted lists of integers. Each class in the program need a class invariant. There should be no limit on the length of the list. The operations on sorted lists of integers supported by IntSortedList are

• A default constructor that creates an empty list of integers.

• An operation named empty that determines if the sorted list is empty. The operation takes no argument and returns a Boolean value.

An operation named length that returns the number of items on the sorted list. The operation takes no argument and returns a positive integer.

• An operation named insert that inserts an integer to the sorted list while maintaining its sorted-ness. The operation takes the integer to insert as its only argument. It should always succeed.

• An operation named delete that deletes an integer from the sorted list. The operation takes the integer to delete as its only argument. It returns true if the integer was in the sorted list. Otherwise, it returns false. Only one

occurrence of the target is deleted by this operation.

• An operation named show that displays the integers in the sorted list on screen. Every row except the last one contains 8 integers separated by spaces.

The last row may contain less than 8 integers.

You are required to provide an array-based implementation of IntSortedList and write a program that makes use of IntSortedList. Follow the following steps.

1. Refine the above specification of IntSortedList by writing function prototypes for its operations and their pre/post conditions.

2. Write a class definition for IntSortedList. The only public methods in the class definition are those operations. The private members are instance variables that represent a sorted list of integers. Write an invariant on these instance variables as comments. You can have private methods that are auxiliary to public ones.

3. Write a program that reads from keyboard a sequence of positive integers that is ended with a negative integer. The positive integers are inserted into a sort list of integers when they are read. When the program finishes reading, it displays the following information on screen: (a) the number of positive integers that have been read; (b) the positive integers.

Reference no: EM131323849

Questions Cloud

Frequency of the third harmonic for the pipe : Consider a pipe with a length of 43.5 cm. If the temperature of the air is 19.5 oC and the pipe is closed in one end and open in the other, what is the frequency of the third harmonic for the pipe? Post your answer in hertz (Hz) and with 3 signifi..
Create multiple functions with the same name : Function overloading is a feature in many programming language, which means that you can create multiple functions with the same name but the parameters within the functions should be different.
Concentration of ammonia in the final solution : If you take a 10.0 mL portion of a 14.8 M ammonia solution and dilute it to a total volume of 0.250 L, what is the concentration of ammonia in the final solution? Provide an answer correct to 2 significant figures.
Identify two evidence based practice models : Discuss why using research studies from peer reviewed journals is important to the development of knowledge in social work. For example, discuss the advantages of having articles reviewed by other scholars and researchers. Then using a case illus..
Write a program that reads from keyboard a sequence : Write a program that reads from keyboard a sequence of positive integers that is ended with a negative integer. The positive integers are inserted into a sort list of integers when they are read.
What is the price elasticity : What is the price elasticity if 200 million people are insured? What is the price elasticity if 220 million people are insured?
Write an interpersonal communication research report : Write the given paper assignment.- Write an interpersonal communication research report, which contains self-analysis.
Evaluate concepts of the melting pot and the american mosaic : Evaluate the concepts of the melting pot and the American mosaic. Which concept more accurately reflects the experiences of the ethnic group you chose? Support your assertion.
What is utility function : Miguel considers tickets to the Houston Grand Opera and to Houston Astros baseball games to be perfect substitutes. Show his preference map. What is his utility function?

Reviews

Write a Review

JAVA Programming Questions & Answers

  Subtract the immediate constant

Call a procedure at 5120, stacking the return address Subtract the immediate constant 16 from the stack pointer Compare the actual parameter to the immediate constant 4 Jump if equal to 5152

  Program that takes the amount a person has spent

Program that takes the amount a person has spent and determines the discount ($15 per $175 spent).

  Determining the taylor series

Suppose that you are told that the Taylor series of f(x)=x3ex^3 about x = 0 is x3+x6+(x9/2!)+(x12/3!)+(x15/4!)+...

  Read the article titled teaching software componentization

read the article titled teaching software componentization a bar chart java bean.write a page paper in which

  Write down a java program which prints out division by zero

write a java program that prints out division by zero and array out of bounds exceptions when a user attempts to find

  Design an object hierarchy

Design an object hierarchy and design your own UML class diagram to reflect the classes and relationship required by your program.

  Write a declaration for three classes using the inheritance

Write a declaration for all three classes using the principles of inheritence. Make the Building class abstract

  Describe the airlines information management system project.

i require assistance in finalizing the requirements model for the Airlines Information Management System (AIMS) project. The requirements model need to include use UML case diagrams for the entire AIM system.

  Write a test application name employeetest

Create two Employee objects and display each objects yearly salary. Then give each employee a 10% raise and display each employee's yearly salary again.

  Primary care-secondary care and tertitary care

Discuss the differences among primary care, secondary care, and tertitary care and the 6 C's of primary care

  What are bufferedinput/outputstreams

What are BufferedInput/OutputStreams and why are they used? Write some Java code to illustrate how to create a BufferedInputStream.

  Program obtaining the new scriptdownload and save the

program obtaining the new scriptdownload and save the attached comment cgi mailer script form-mail2.pl to your servers

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