Write a method compact that removes all zeroes

Assignment Help JAVA Programming
Reference no: EM13691703

Question: Please help me with the subsequent.

Question 1.Write a program that reads a text file (compact.txt) and stores the integers in an array.  Your instructor will provide this text file.

Question 2. Write a method compact that removes all zeroes from the array, leaving the order of the other elements unchanged.  All local variables within this function must be scalar.  In other words, you may not use a second array to solve the problem.

Question 3. Do not solve the problem by printing out only the non-zero values in the array.  The compactmethod must remove all zeros from the array.

Instructions:

Part 1. Print out the list both before and after removing the zeros.  For example:

Before:  0, 9, 7, 0, 0, 23, 4, 0

After:  9, 7, 23, 4

Part 2. Your program must use proper modular design and parameter passing.

Reference no: EM13691703

Questions Cloud

Create a database to control its local libraries : A county wishes to create a database to control its local libraries. Each library has a number of employees, one of whom is designated as the manager of the library and is responsible for supervising employees and the general day-to-day management..
Suggest three ddl and three dml commands : Describe a specific scenario, situation, or application where using a foreign key would be necessary and explain your reasons, including the characteristics of the data, that necessitate the foreign key.
Problematic programming situation : Suggest one example of a problematic programming situation or scenario that the use or implementation of a loop structure could resolve. Justify your response.
Program that will read in 8 numbers into an array : Write a program that will read in 8 numbers into an array. Print out the numbers from the array, then print the 2nd number, the 5th number and the last number.
Write a method compact that removes all zeroes : Write a program that reads a text file (compact.txt) and stores the integers in an array.  Your instructor will provide this text file.
Write a program which initialize an integer array : Write a program which performs the tasks - return the control to main( )and print the new array elements in main.
Steps in preparing a high level language program : Describe the purpose of each step in preparing a high level language program for execution (editing, compiling, linking, and loading).  Include in your description the types of files created with each of the first three steps.?
Give an algorithm that returns the position : Give an algorithm that returns true if a string contains properly nested and balanced parentheses, and false if otherwise. Hint: At no time while scanning a legal string from left to right will you have encountered more right parentheses than left..
Define an adt for character strings : Define an ADT for character strings. Your ADT should consist of typical functions that can be performed on strings, with each function defined in terms of its input and output. Then define two different physical representations for strings.

Reviews

Write a Review

JAVA Programming Questions & Answers

  Write a program that plays a word game with the user

Write a program that plays a word game with the user. The program should ask the user to enter the following.

  Given the following data definition classpublic class exam

given the following data definition classpublic class exam private static int totalpublic static void settotalint t

  Implement a shopping cart class with user interface

project will be to implement a shopping cart class with user interface (UI) that contains main() in Net Beans. The UI class will be used to perform user input/output and to invoke the appropriate methods of shopping cart class. When your program star..

  Create a java class called samearraysexception

Create a Java class called SameArraysException that extends the Exception class.

  Design a function named "falling distance"

Design a function named "fallingDistance" that accepts an objects falling time, in seconds, as an argument. The function should return the distance, in meters, that the object has fallen during that time interval. Design a program that calls the func..

  Write a method that reads the contents of the two files

BoyNames.txt This file contains a list of the 20 most popular names given to boys born in the US in 2011.

  Dangerousmonster which inherits the monster

An interface - DangerousMonster which inherits the Monster interface and has a method called destroy() with void return type.(Note: Just like a class can inherit from another class, an interface can inherit from another interface using the "extends..

  Program that counts the number of occurrences of lowercase

Write a program that counts the number of occurrences of lowercase and uppercase vowels in entered lines of text. Use a two-dimensional array to store the vowel counts. The array's first column holds the counts for the lowercase vowels, and the secon..

  standard graph with four quadrant

Write a program in java that asks the user for values of x and y, and displays the point as an ordered pair along with a message that describes where that point falls on the standard graph with four quadrant.

  Redesign the grading program as an object-oriented design

redesign the grading program as an object-oriented design. We will start with a simple Student class. The student will have a name, an id (as a String) and a set of grades (as doubles)

  Implement a client program

Implement a client program with a main method to demonstrate the evolution of the sales tax rates in the 50 US states over the last 10 years. Declare a two-dimensional array of values representing the sales tax rates. Dimension 1 represents the st..

  Dijikstra for undirected graph using simple scheme with

dijikstra for undirected graph using simple scheme with array and fibonacci heap and compare the performanceresults

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