All Matches
Solution Library
Expert Answer
Textbooks
Search Textbook questions, tutors and Books
Oops, something went wrong!
Change your search query and then try again
Toggle navigation
FREE Trial
S
Books
FREE
Tutors
Study Help
Expert Questions
Accounting
General Management
Mathematics
Finance
Organizational Behaviour
Law
Physics
Operating System
Management Leadership
Sociology
Programming
Marketing
Database
Computer Network
Economics
Textbooks Solutions
Accounting
Managerial Accounting
Management Leadership
Cost Accounting
Statistics
Business Law
Corporate Finance
Finance
Economics
Auditing
Ask a Question
Search
Search
Sign In
Register
study help
computer science
java how to program late objects
Questions and Answers of
Java How To Program Late Objects
Write an application that reads a five-letter word from the user and produces every possible three-letter string that can be derived from the letters of that word. For example, the three-letter words
String manipulation enables interesting approaches to analyzing the writings of great authors. Much attention has been focused on whether William Shakespeare ever lived.Some scholars believe
Dates are printed in several common formats. Two of the more common formats are 04/25/1955 and April 25, 1955 Write an application that reads a date in the first format and prints it in the second
Computers are frequently employed in check-writing systems, such as payroll and accounts payable applications. There are many strange stories about weekly paychecks being printed (by mistake) for
Perhaps the most famous of all coding schemes is the Morse code, developed by Samuel Morse in 1832 for use with the telegraph system. The Morse code assigns a series of dots and dashes to each letter
Write an application that will assist the user with metric conversions. Your application should allow the user to specify the names of the units as strings (i.e., centimeters, liters, grams, and so
Many apps you use daily have built-in spell checkers. In this project, you’re asked to develop your own spell-checker utility. We make suggestions to help get you started. You should then consider
Most people have worked a crossword puzzle, but few have ever attempted to generate one. Generating a crossword puzzle is suggested here as a stringmanipulation project requiring substantial
Obesity in America is increasing at an alarming rate. Check the map from the Centers for Disease Control and Prevention (CDC) at http://www.cdc.gov/obesity/data/adult.html, which shows obesity trends
Spam (or junk e-mail) costs U.S. organizations billions of dollars a year in spam-prevention software, equipment, network resources, bandwidth, and lost productivity.Research online some of the most
Short Message Service (SMS) is a communications service that allows sending text messages of 160 or fewer characters between mobile phones. With the proliferation of mobile-phone use worldwide, SMS
It’s possible (and actually common) to have several transaction records with the same record key. This situation occurs, for example, when a customer makes several purchases and cash payments
Recreate your solution for Exercise 15.5 using XML serialization. You may want to create applications to read the data stored in the .xml files—the code in Section 15.5.2 can be modified for this
Standard telephone keypads contain the digits zero through nine. The numbers two through nine each have three letters associated with them (Fig. 15.19). Many people find it difficult to memorize
Encryption is the process of encoding messages in order to prevent unauthorized parties from reading them. The reverse operation is decryption which aims to restore the original messages. The Caesar
Phishing is a form of identity theft in which, in an e-mail, a sender posing as a trustworthy source attempts to acquire private information, such as your user names, passwords, credit-card numbers
Briefly answer the following questions:a) What is the primary difference between a Set and a Map?b) What happens when you add a primitive type (e.g., double) value to a collection?c) Can you print
Explain briefly the operation of each of the following Iterator-related methods:a) Iteratorb) HasNextc) Next
What will happen in the following cases?a) Using BinarySearch with an unsorted list.b) Using an Iterator operation after modifying its related collection.c) Creating an object of HashSet using a
Determine whether each of the following statements is true or false. If false, explain why.a) Vectors are synchronized by default.b) Class Stack does not have a method add.c) In order to use the
Rewrite lines 10–25 in Fig. 16.3 to be more concise by using the asList method and the LinkedList constructor that takes a Collection argument.Fig. 16.3 1 // Fig. 16.3: ListTest.java // Lists,
Write a program that reads in a series of first names and eliminates duplicates by storing them in a Set. Allow the user to search for a first name.
Write a class AccountComparator to implement the Comparator interface for class Account in Figure 15.9 based on the account’s balance. Use this class in order to sort a list of accounts in
Write an application to implement the three Set operations: interaction, union, and difference. You should build three methods corresponding to the operations. In your main method, test these methods
Write a program that has a method ListConcatenate which receives two objects of LinkedList, and returns a new LinkedList that contains elements of the first list followed by elements of the second
Write a program that takes a whole number input from a user and determines whether it’s prime. If the number is not prime, display its unique prime factors. Remember that a prime number’s factors
Write a program that uses a String method split to tokenize a line of text input by the user and places each token in a TreeSet. Print the elements of the TreeSet.
The output of Fig. 16.14 shows that Priority-Queue orders Double elements in ascending order. Rewrite Fig. 16.14 so that it orders Double elements in descending order (i.e., 9.8 should be the
Create a class that mixes two LinkedLists of numbers. Your class should include a static method mixList that takes the references of two LinkedLists as arguments and inserts the numbers in the second
Assuming that list is a List, explain in detail the stream pipeline: 1234 4 list.stream() .filter(value .distinct() .count() -> value < 0)
Modify the program of Fig. 17.22 to summarize the number of occurrences of every character in the file.Fig. 17.22 1 // Fig. 17.22: StreamOfLines.java 2 // Counting word occurrences in a text file. 4
How to get informationabout files and directories on disk. In addition, you used a DirectoryStream to display the contents of a directory. Interface DirectoryStream now contains default method
Use the class Invoice provided in the exercises folder with this chapter’s examples to create an array of Invoice objects. Use the sample data shown in Fig. 17.25. Class Invoice includes four
Write a program to generate ten random integers between zero and a thousand, then display how many of them are odd and how many are even; also display the average of: all numbers, odd numbers, and
Write a program that reads phone directory records from a text file. Each line in the text file represents a record composed of a first name, a last name, and a phone number separated by spaces. Your
Answer the following questions with regard to the stream pipeline in Fig. 17.7:a) How many times does the filter operation call its lambda argument?b) How many times does the map operation call its
Modify the Stream example that it uses stream capabilities to display the average Employee salary by department.
The example of Fig. 17.7 summed the triples of the even integers from 2 through 10. We used filter and map in the stream pipeline to demonstrate both in one stream pipeline. Reimplement Fig. 17.7’s
Figures 4.8 and 4.10 demonstrated calculating a class average with counter-controlled repetition and sentinel-controlled repetition, respectively. Create a program that reads integer grades and
Create a program that reads integer grades and stores them in an ArrayList, then use stream processing to display each grade’s letter equivalent (A, B, C, D or F).Response to comment:I assume it is
Defined a two-dimensional array of grades with 10 rows and three columns, representing 10 students’ grades on three exams. Use a stream pipeline to calculate the average of all the grades. For this
Defined a two-dimensional array of grades with 10 rows and three columns, representing 10 students’ grades on three exams. Use streams to calculate the students’ individual averages.
Create a collection of Person objects in which each Person has a firstName and a lastName. Use streams to locate the first Person object containing the last name Jones. Ensure that several Person
Use an infinite stream of integers to display the first n prime numbers, where n is input by the user.
In Fig. 17.24, we implemented a stream pipeline that rolled a die 60,000,000 times using values produced by SecureRandom method ints. Package java.time contains types Instant and Duration that you
Write a recursive method that is equivalent to the following iterative method: 1 2 3 4 5 6 int mystery (int x) { int sum = 0; for(int i = x; i > 0; i--) sum = sum + 1; return sum }
What does the following code do? There is a statement after the recursive call which should be executed for each call. I 23456 public void printInt (int n) { if (n != 0) { printInt(n 1);
Write a recursive method power(base, exponent) that, when called, returns base exponent For example, power(3,4) = 3 * 3 * 3 * 3. Assume that exponent is an integer greater than or equal to 1. The
It’s interesting to watch recursion “in action.” Modify the factorial method in Fig.18.3 to print its local variable and recursive-call parameter. For each recursive call, display the outputs
The greatest common divisor of integers x and y is the largest integer that evenly divides into both x and y. Write a recursive method gcd that returns the greatest common divisor of x and y. The gcd
Euler’s number, e, is the base of the natural logarithm, and is widely used in engineering, science and business. The value of e can be approximated using the formulaWrite a recursive method to
A puzzler for chess buffs is the Eight Queens problem, which asks: Is it possible to place eight queens on an empty chessboard so that no queen is “attacking” any other (i.e., no two queens are
Write a recursive method searchArray that searches for an element in an array of integers, and returns its position or -1 if it is not found.
Write a recursive method stringReverse that takes a character array containing a string as an argument and prints the string backward.
Write a recursive method recursiveMinimum that determines the smallest element in an array of integers. The method should return when it receives an array of one element.
Repeat the fractal pattern form a star with several colors. Begin with five lines (see Fig. 18.22 ) instead of one, where each line is a different arm of the star. Apply the “Lo feather fractal”
The grid of #s and dots (.) in Fig. 18.23 is a two-dimensional array representation of a maze. The #s represent the walls of the maze, and the dots represent locations in the possible paths through
Write a method mazeGenerator that takes as an argument a two-dimensional 12-by-12 character array and randomly produces a maze. The method should also provide the starting and ending locations of the
Enhance the Fibonacci program of Fig. 18.5 so that it calculates the approximate amount of time required to perform the calculation and the number of calls made to the recursive method. For this
Using the techniques you learned in Section 18.9, implement an application that draws the Koch Curve. 18.9.1 Koch Curve Fractal As an example, let's look at the strictly self-similar Koch Curve
Research the Koch Snowflake online then, using the techniques you learned in Section 18.9, implement an application that draws the Koch Snowflake. 18.9.1 Koch Curve Fractal As an example, let's look
Using the String-processing capabilities, the file and directory capabilities and a Map, create an application that recursively walks a directory structure supplied by the user and reports the number
Each of the counter-controlled for loops we used in this chapter’s examples can be implemented using IntStream’s rangeClosed method to produce a range of values, then using IntStream’s forEach
Reimplement the factorial methods of Figs. 18.3 –18.4 to calculate factorials using lambdas and streams, rather than recursion.Fig. 18.3Fig. 18.4 1 // Fig. 18.3: Factorial Calculator.java //
Reimplement the fibonacci method of Fig. 18.5 to calculate Fibonacci numbers using lambdas and streams, rather than recursion.Fig. 18.5 I // Fig. 18.5: FibonacciCalculator.java // Recursive fibonacci
A bucket sort begins with a one-dimensional array of positive integers to be sorted and a two-dimensional array of integers with rows indexed from 0 to 9 and columns indexed from 0 to n – 1, where
Write a method recursiveBubbleSort that uses recursive techniques to perform an ascending bubble sort on an array of integers. The method should receive the array and an integer representing the
Write a method insertionRecursiveSort that implements an insertion sort using recursive techniques.
The recursive sorting technique called quicksort uses the following basic algorithm for a one-dimensional array of values:a) Partitioning Step: Take the first element of the unsorted array and
In earlier chapters, we showed how computers can help improve the learning process. In this chapter, you studied a variety of sorting algorithms. Each has the same goal—to produce a sorted
Assuming GClass is a generic class, what is wrong with the following statement:GClass obj = new GClass();
Write a generic method reverseArray that reverses the order of elements in an array. Use this generic method in a program to reverse arrays of different types.Print each array both before and after
Overload generic method printArray of Fig. 20.3 so that it takes two additional integer arguments, lowSubscript and highSubscript. A call to this method prints only the designated portion of the
Overload generic method printArray of Fig. 20.3 with a nongeneric version that specifically prints an array of Strings in neat, tabular format, as shown in the sample output that follows:Fig. 20.3
Write a generic class Pair which has two type parameters—F and S—each representing the type of the first and second element of the pair, respectively. Add get and set methods for the first and
Can a generic method be overloaded with a nongeneric method?
Explain why a Java program might use the statement List workerList = new ArrayList();
Modify the method created in Exercise 5.18 to receive a second parameter of type char called fillCharacter. Form the square using the char provided as an argument. Thus, if side is 5 and
Modify the application you wrote in Exercise 4.24 to read an odd number in the range 1 to 19 to specify the number of rows in the diamond. Your program should then display a diamond of the
A criticism of the break statement and the continue statement is that each is unstructured. Actually, these statements can always be replaced by structured statements, although doing so can be
What does the following program segment do? -2345678901 for (i = 1; i
Modify Exercise 4.15 to combine your code from the four separate triangles of asterisks such that all four patterns print side by side.Exercise 4.15Write an application that displays the following
Write an application that uses iteration and switch statements to print the song “The Twelve Days of Christmas.” One switch statement should be used to print the day (“first,” “second,”
The controversial issue of global warming has been widely publicized by the film “An Inconvenient Truth,” featuring former Vice President Al Gore. Mr. Gore and a U.N. network of scientists, the
There are many proposals to make taxation fairer. Check out the FairTax initiative in the United States at http://www.fairtax.org. Research how the proposed FairTax works. One suggestion is to
For the class Craps in Fig. 5.8, state the scope of each of the following entities:a) the variable randomNumbers.b) the variable die1.c) the method rollDice.d) the method main.e) the variable
Write an application that tests whether the examples of the Math class method calls shown in Fig. 5.2 actually produce the indicated results.Fig. 5.2 Method abs (x) ceil(x) cos(x) exp(x) floor (x)
Find the error in each of the following program segments. Explain how to correct the error.a)b)c)d) Ivoid go { 234567 System.out.println("Inside method g"); void h() { 6 } 7 }
What is the value of x after each of the following statements is executed?a) x = Math.abs(-7.5);b) x = Math.floor(5 + 2.5);c) x = Math.abs(9) + Math.ceil(2.2);d) x = Math.ceil(-5.2);e) x =
A parking garage charges a $2.00 minimum fee to park for up to three hours. The garage charges an additional $0.50 per hour for each hour or part thereof in excess of three hours. The maximum charge
Math.floor can be used to round values to the nearest integer—e.g.,double y = Math.floor(x + 0.5);will round the number x to the nearest integer and assign the result to y. Write an application
To round numbers to specific decimal places, use a statement like double y = Math.floor(x * 10 + 0.5) / 10;which rounds x to the tenths position (i.e., the first position to the right of the decimal
Write statements that assign random integers to the variable n in the following ranges: a) 2n 6. b) 4 n 50. c) 0 < n 7. 1000 n 1030. d) e) -5 n 1. f) -2 n9.
Write statements that will display a random number from each of the following sets:a) 0, 3, 6, 9, 12.b) 1, 2, 4, 8, 16, 32.c) 10, 20, 30, 40.
Write two methods myFloor and myCeil that take a positive double num variable int myFloor(double num) and int myCeil(double num). The myFloor method takes num and returns the largest integer number
Define a method hypotenuse that calculates the hypotenuse of a right triangle when the lengths of the other two sides are given. The method should take two arguments of type double and return the
Write a method isMultiple that determines, for a pair of integers, whether the second integer is a multiple of the first. The method should take two integer arguments and return true if the second is
Write a method isDivisible that uses the remainder operator (%) to determine whether ten input integers are divisible by 5 or not. The method should take an integer argument and return true if the
Write a method squareOfAsterisks that displays a solid square (the same number of rows and columns) of asterisks whose side is specified in integer parameter side. For example, if side is 4, the
Write an application that prompts the user to enter an year and uses a method called isLeapYear to check whether it is a leap year.
Showing 200 - 300
of 421
1
2
3
4
5