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 an introduction to problem solving and progra
Questions and Answers of
Java An Introduction to Problem Solving and Progra
Modify the program in the previous exercise so that it reads the name of the file from the keyboard.Previous exerciseWrite a program that will write the Gettysburg Address to a text file. Place each
Write a program similar to the one in Listing 10.10 that can write an arbitrary number of Species objects to a binary file. (Species appears in Listing 5.19 of Chapter 5.) Read the file name and the
Write some code that asks the user to enter either of the words append or new. According to the user response, open either an existing text file to which data can be appended or a new, empty text
Write a program that reads from a file created by the program in the previous programming project and displays the following information on the screen: the data for the species having the smallest
Write a program that will record the purchases made at a store. For each purchase, read from the keyboard an item’s name, its price, and the number bought. Compute the cost of the purchase (number
Programming Project 2 asks you, among other things, to write a program that creates a binary file of objects of the class Species. Write a program that reads from a file created by that program and
Modify the class LapTimer, as described in Exercise 13 of Chapter 9, as follows:Add an attribute for a file stream to which we can write the timesAdd a constructorLapTimer(n, person, fileName)for a
Text messaging is a popular means of communication. Many abbreviations are in common use but are not appropriate for formal communication. Suppose the abbreviations are stored, one to a line, in a
Write a class TelephoneNumber that will hold a telephone number. An object of this class will have the attributesareaCode—a three-digit integerexchangeCode—a three-digit integernumber—a
Modify the TelephoneNumber class described in Exercise 6 so that it is serializable. Write a program that creates an array whose base type is TelephoneNumber by reading data from the keyboard. Write
Write a class ContactInfo to store contact information for a person. It should have attributes for a person’s name, business phone, home phone, cell phone, e-mail address, and home address. It
Revise the class Pet, as shown in Listing 6.1 of Chapter 6, so that it is serializable. Write a program that allows you to write and read objects of type Pet to a file. The program should ask the
Write a program that reads every line in a text file, removes the first word from each line, and then writes the resulting lines to a new text file.
Write a program that reads records of type Pet from a file created by the program described in the previous programming project and displays the following information on the screen: the name and
Repeat the previous exercise, but write the new lines to a new binary file instead of a text file.Previous exerciseWrite a program that reads every line in a text file, removes the first word from
Write a program that will make a copy of a text file, line by line. Read the name of the existing file and the name of the new file—the copy—from the keyboard. Use the methods of the class File
In many races competitors wear a RFID tag on their shoes or bibs. When the racer crosses a sensor a computer logs the racer’s number along with the current time. Sensors can be placed along the
Suppose you are given a text file that contains the names of people. Every name in the file consists of a first name and last name. Unfortunately, the programmer who created the file of names had a
Based on the log file described in Programming Project 10 write a program to detect cheating.This could occur if:A racer misses a sensor, which is a sign that the racer may have taken a shortcut.A
Suppose that you have a binary file that contains numbers whose type is either int or double. You don’t know the order of the numbers in the file, but their order is recorded in a string at the
Write a Java program that serves as a primitive web browser. For this assignment it merely needs to input a server name and display the HTML that is sent by the web server. A web server normally
Suppose that we want to store digitized audio information in a binary file. An audio signal typically does not change much from one sample to the next. In this case, less memory is used if we record
Repeat any of the previous programming projects using a JavaFX graphical user interface.Previous programming projectsWrite a Java program that serves as a primitive web browser. For this assignment
Write a program RecoverSignal that will read the binary file written by StoreSignal, as described in the previous exercise. Display the integer values that the data represents on the screen.
Write a JavaFX application that uses a text field to get the name of a file, reads the file byte by byte, and displays the bytes as characters. (Exercise 15 describes how to convert a byte value to a
Even though a binary file is not a text file, it can contain embedded text. To find out if this is the case, write a program that will open a binary file and read it one byte at a time. Display the
A palindrome is a string that reads the same forward and backward, such as "radar". Write a static recursive method that has one parameter of type String and returns true if the argument is a
What output will be produced by the following code?public class Demo{public static void main(String[] args){System.out.println("The output is:");foo(23);System.out.println();}public static void
What output will be produced by the following code?public class Demo{public static void main(String[] args){System.out.println("The output is:");bar(11156);System.out.println();}public static void
Write a recursive method that will compute the number of odd digits in a number.
The Fibonacci sequence occurs frequently in nature as the growth rate for certain idealized animal populations. The sequence begins with 0 and 1, and each successive Fibonacci number is the sum of
Write a recursive method that will compute the sum of the digits in a positive number.
Imagine a candy bar that has k places where it can be cut. You would like to know how many different sequences of cuts are possible to divide the bar into pieces. For example, if k is 3, you could
Once upon a time in a kingdom far away, the king hoarded food and the people starved. His adviser recommended that the food stores be used to help the people, but the king refused. One day a small
Write a recursive method that will compute the sum of all the values in an array.
Write a recursive method that will find and return the largest value in an array of integers. Split the array in half and recursively find the largest value in each half. Return the larger of those
Given the definition of a 2D array such as the following:String[][] data = {{"A","B"},{"1","2"},{"XX","YY","ZZ"}};write a recursive program that outputs all combinations of each subarray in order. In
Write a recursive ternary search algorithm that splits the array into three parts instead of the two parts used by a binary search.
Write a recursive method that will compute cumulative sums in an array. To find the cumulative sums, add to each value in the array the sum of the values that precede it in the array. For example, if
A description of the File class is available on Oracle’s Java Web site at http:// docs.oracle.com/javase/7/docs/api/java/io/File.html. To use this class you must import java.io.File. For this
Suppose we want to compute the amount of money in a bank account with compound interest. If the amount of money in the account is m, the amount in the account at the end of the month will be 1.005m.
Create a JavaFX application that will draw a fractal curve using line segments. Fractals are recursively defined curves. The curve you will draw is based on a line segment between points p and p :To
Suppose we have a satellite in orbit. To communicate to the satellite, we can send messages composed of two signals: dot and dash. Dot takes 2 microseconds to send, and dash takes 3 microseconds to
Do Programming Project 17 from Chapter 4, the Edoc calculator, except use a recursive function to calculate or help you calculate the maximum amount of experience points you can earn.Project 17 from
Write a recursive method that will count the number of vowels in a string. Each time you make a recursive call, use the String method substring to construct a new string consisting of the second
Do Programming Project 9 from Chapter 8 using lambda functions to implement the button click events.Programming Project 9Create a JavaFX application that acts as a simple calculator. Create buttons
Write a recursive method that will remove all the vowels from a given string and return what is left as a new string. Use the + operator to perform string concatenation to construct the string that
Write a recursive method that will duplicate each character in a string and return the result as a new string. For example, if "book" is the argument, the result would be "bbooookk".
Write a recursive method that will reverse the order of the characters in a given string and return the result as a new string. For example, if "book" is the argument, the result would be "koob".
Repeat Exercise 2 in Chapter 7, but use an instance of ArrayList instead of an array. Do not read the number of values, but continue to read values until the user enters a negative value.Exercise 2
Write a program that creates Pet objects from data read from the keyboard. Store these objects into an instance of ArrayList. Then sort the Pet objects into alphabetic order by pet name, and finally
Repeat Exercise 3 in Chapter 7, but use an instance of ArrayList instead of an array. Do not read the number of families, but read data for families until the user enters the word done.Exercise 3 in
Repeat the previous programming project, but sort the Pet objects by pet weight instead of by name. After displaying the sorted data on the screen, write the number and percentage of pets that are
Repeat Exercise 5 in Chapter 7, but use an instance of ArrayList instead of an array.Exercise 5 in Chapter 7Write a program in a class CharacterFrequency that counts the number of times a digit
Repeat the previous programming project, but read the input data from a file and send the output to another file. If you have covered binary files, use binary files; otherwise, use text files. Read
Repeat Exercises 6 and 7 in Chapter 7, but use an instance of ArrayList instead of an array. We will no longer need to know the maximum number of sales, so the methods will change to reflect
Use the class ClassObjectIODemo shown in Listing 10.10 of Chapter 10 to create a file of Species objects. The class Species is given in Chapter 10, Listing 10.9. Then write a program that reads the
Write a static method removeDuplicates(ArrayList data) that will remove any duplicates of characters in the object data. Always keep the first copy of a character and remove subsequent ones.
Define a variation on StringLinkedListSelfContained from Listing 12.7 that stores objects of type Species, rather than of type String. Write a program that uses that linked-list class to create a
Write a static methodgetCommonStrings(ArrayList list1,ArrayList list2)that returns a new instance of ArrayList containing all of the strings common to both list1 and list2.
Repeat the previous programming project, but read the input data from a file and send the output to another file. If you have covered binary files, use binary files; otherwise, use text files. Read
Write a program that will read sentences from a text file, placing each sentence in its own instance of ArrayList. (You will create a sentence object by adding words to it one at a time as they are
Define a variation on StringLinkedListSelfContained from Listing 12.7 that stores objects of type Employee, rather than objects of type String. Write a program that uses this linked-list class to
Repeat Exercise 12 in Chapter 7, but use an instance of ArrayList instead of an array. Make the following slight changes to the methods to reflect that an ArrayList object can grow in size:Change the
Repeat the previous programming project, but read the input data from a file and send the output to another file. If you have covered binary files, use binary files; otherwise, use text files. Read
Write a program that will read a text file that contains an unknown number of movie review scores. Read the scores as Double values and put them in an instance of ArrayList. Compute the average score.
Write a parameterized class definition for a doubly linked list that has a parameter for the type of data stored in a node. Make the node class an inner class. Choosing which methods to define is
Revise the class StringLinkedList in Listing 12.5 so that it can add and remove items from the end of the list.Listing 12.5public class StringLinkedList{private ListNode head;public
Create an application that will keep track of several groups of strings. Each string will be a member of exactly one group. We would like to be able to see whether two strings are in the same group
Suppose we would like to create a data structure for holding numbers that can be accessed either in the order that they were added or in sorted order. We need nodes having two references. If you
For this project, we will create a data structure known as a queue. A queue can be thought of as a line. Items are added at the end of the line and are taken from the front of the line. You will
Draw a picture of an initially empty data structure, as described in the previous exercise, after adding the numbers 2, 8, 4, and 6, in this order.
Repeat the previous programming project, but use a circular linked list to implement the queue. Recall from Figure 12.10 that a circular linked list has one external reference, which is to the
Write some code that will use an iterator to duplicate every item in an instance of StringLinkedListWithIterator in Listing 12.9. For example, if the list contains "a", "b", and "c", after the code
Suppose that we would like to perform a bird survey to count the number of birds of each species in an area. Create a class BirdSurvey that is like one of the linked-list classes given in this
Consider a text file of names, with one name per line, that has been compiled from several different sources. A sample is shown below:Brooke TroutDinah SoarsJed DyeBrooke TroutJed DyePaige
Write some code that will use an iterator to interchange the items in every pair of items in an instance of StringLinkedListWithIterator in Listing 12.9. For example, if the list contains "a", "b",
You have a list of student ID’s followed by the course number (separated by a space) that the student is enrolled in. The listing is in no particular order. For example, if student 1 is in CS100
The class StringLinkedListWithIterator (Listing 12.9) is its own iterator, but it does not quite implement the Java Iterator interface. Redefine the class StringLinkedListWithIterator so that it
Write a program that creates two instances of the generic class LinkedList given in Listing 12.12. The first instance is stadiumNames and will hold items of type String. The second instance is
Write a program that checks a text file for several formatting and punctuation matters. The program asks for the names of both an input file and an output file. It then copies all the text from the
Write a program that will write the Gettysburg Address to a text file. Place each sentence on a separate line of the file.
Show the modifications needed to add exponentiation to the class Calculator in Listing 9.12. Use ^ to indicate the exponentiation operator and the method Math.pow to perform the computation.Listing
Write an application that implements a trip-time calculator. Define and use a class TripComputer to compute the time of a trip. TripComputer should have the private attributestotalTime—the total
Revise the class RoomCounter described in the previous exercise to use an assertion instead of an exception to prevent the number of people in the room from becoming negative.Previous exerciseSuppose
Suppose that you are in charge of customer service for a certain business. As phone calls come in, the name of the caller is recorded and eventually a service representative returns the call and
Suppose that you are going to create an object used to count the number of people in a room.We know that the number of people in the room can never be negative. Create a RoomCounter class having
Write a JavaFX program that moves an image toward the location of the mouse. The image shouldn’t jump directly to the mouse coordinates (which is what happens in Listing 9.16) but should move a few
Revise the class Rational described in the previous exercise to use an assertion instead of an exception to guarantee that the denominator is never zero.Previous exerciseCreate a class Rational that
Modify the Bouncing Ball example from Listing 9.18, except instead of animating a red circle, animate an image of your choice.Listing 9.18import javafx.application.Application;import
Create a class Rational that represents a rational number. It should have private attributes forThe numerator (an integer)The denominator (an integer) and the following methods:Rational(numerator,
Create a JavaFX application that implements a short survey. The first question should ask the user for his or her favorite color and present the choices “red”, “orange”, “blue”, and
Create a class SongCard that represents a gift card for the purchase of songs online. It should have the following private attributes:songs—the number of songs on the cardactivated—true if the
Write a program to enter employee data, including Social Security number and salary, into an array. The maximum number of employees is 100, but your program should also work for any number of
Write code that reads a string from the keyboard and uses it to set the variable myTime of type TimeOfDay from the previous exercise. Use try-catch blocks to guarantee that myTime is set to a valid
Define an exception class called DimensionException to use in the driver program from Programming Project 4 in Chapter 8. Modify that driver program to throw and catch a DimensionException if the
Write a class TimeOfDay that uses the exception classes defined in the previous exercise. Give it a method setTimeTo(timeString) that changes the time if timeString corresponds to a valid time of
Modify the driver program from Practice Program 3 in Chapter 8 to use three exception classes called CylinderException, LoadException, and TowingException. The number of cylinders must be an integer
Derive exception classes from the class you wrote in the previous exercise. Each new class should indicate a specific kind of error. For example, InvalidHourException could be used to indicate that
Write a program that converts dates from numerical month-day format to alphabetic month-day format. For example, input of 1/31 or 01/31 would produce January 31 as output. The dialogue with the user
Showing 100 - 200
of 407
1
2
3
4
5