Java: An Introduction to Problem Solving and Programming (7th Edition)
7th Edition
ISBN: 9780133766264
Author: Walter Savitch
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 12, Problem 9E
Write a
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Write a program that uses an object of type ServiceRequests to keep track of customers that have called. It should have a loop that, in each iteration, attempts to add a name, remove a name, or print all names. Use an array of size 10 as the list of names.
1. Copy some text from a news article, paste it in the Notepad++ editor and save it in a textfile named testtext.txt;2. Write a Java program to read the words in the text file into an ArrayList object,display the information about how many words there are in the text file, and display thewords in the order they appear in the text file. Then sort the array and display the sortedarray. Take a screenshot of the output window.3. Submit your text file, the screenshot, and the Java source code file
Computer Science
In java, use while (!StdIn.isEmpty()) to read in a file of strings with 3 letter words. put these strings into an array and choose one word from the array at random. Ask the user to guess the string. If they get it wrong, give them one of the letters, then let them guess again. Keep going until they get the correct answer. then output "Good job, you guessed my word!"
Chapter 12 Solutions
Java: An Introduction to Problem Solving and Programming (7th Edition)
Ch. 12.1 - Suppose aList is an object of the class...Ch. 12.1 - Prob. 2STQCh. 12.1 - Prob. 3STQCh. 12.1 - Prob. 4STQCh. 12.1 - Can you use the method add to insert an element at...Ch. 12.1 - Prob. 6STQCh. 12.1 - Prob. 7STQCh. 12.1 - If you create a list using the statement...Ch. 12.1 - Prob. 9STQCh. 12.1 - Prob. 11STQ
Ch. 12.1 - Prob. 12STQCh. 12.2 - Prob. 13STQCh. 12.2 - Prob. 14STQCh. 12.2 - Prob. 15STQCh. 12.2 - Prob. 16STQCh. 12.3 - Prob. 17STQCh. 12.3 - Prob. 18STQCh. 12.3 - Prob. 19STQCh. 12.3 - Write a definition of a method isEmpty for the...Ch. 12.3 - Prob. 21STQCh. 12.3 - Prob. 22STQCh. 12.3 - Prob. 23STQCh. 12.3 - Prob. 24STQCh. 12.3 - Redefine the method getDataAtCurrent in...Ch. 12.3 - Repeat Question 25 for the method...Ch. 12.3 - Repeat Question 25 for the method...Ch. 12.3 - Repeat Question 25 for the method...Ch. 12.4 - Revise the definition of the class ListNode in...Ch. 12.4 - Prob. 30STQCh. 12 - Repeat Exercise 2 in Chapter 7, but use an...Ch. 12 - Prob. 2ECh. 12 - Prob. 3ECh. 12 - Repeat Exercises 6 and 7 in Chapter 7, but use an...Ch. 12 - Write a static method removeDuplicates...Ch. 12 - Write a static method...Ch. 12 - Write a program that will read sentences from a...Ch. 12 - Repeat Exercise 12 in Chapter 7, but use an...Ch. 12 - Write a program that will read a text file that...Ch. 12 - Revise the class StringLinkedList in Listing 12.5...Ch. 12 - Prob. 12ECh. 12 - Write some code that will use an iterator to...Ch. 12 - Prob. 14ECh. 12 - Write some code that will use an iterator to...Ch. 12 - Prob. 17ECh. 12 - Revise the method selectionSort within the class...Ch. 12 - Repeat the previous practice program, but instead...Ch. 12 - Repeat Practice Program 1, but instead write a...Ch. 12 - Write a program that allows the user to enter an...Ch. 12 - Write a program that uses a HashMap to compute a...Ch. 12 - Write a program that creates Pet objects from data...Ch. 12 - Repeat the previous programming project, but sort...Ch. 12 - Repeat the previous programming project, but read...Ch. 12 - Prob. 9PPCh. 12 - Prob. 10PPCh. 12 - Prob. 11PPCh. 12 - Prob. 12PPCh. 12 - Prob. 13PPCh. 12 - Prob. 14PPCh. 12 - Prob. 15PP
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
The ____________ is always transparent.
Web Development and Design Foundations with HTML5 (8th Edition)
Describe the purpose of the access key attribute and how it supports accessibility.
Web Development and Design Foundations with HTML5 (9th Edition) (What's New in Computer Science)
Show a snippet of PHP code for disconnecting from the database. Explain the meaning of the code.
Database Concepts (7th Edition)
Practice Problem 2.54 (solution page 160) Assume variables x, f, and d are of type int, float, and double, resp...
Computer Systems: A Programmer's Perspective (3rd Edition)
3.12 (Date Create a class called Date that includes three pieces Of information as data
members—a month (type ...
C++ How to Program (10th Edition)
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- The program in Java language. Do not use Java's ArrayList. Your project is to read in a series of fractions from a text file, which will have each line formatted as follows: “A/B”. A sample text file is listed below, and the purpose of your program is to read in each fraction and count the number of occurrences for the current fraction. When all the input is consumed (or as the input is consumed), your program will print out its list of unique fraction and their corresponding count — see the output below (and you may assume no blank lines or misleading characters; see the text file link on the website for one of the actual inputs I’ll use when testing your submission). The fractions should always be represented as two integers - DO NOT USE DECIMALS. Only use arrays to hold your data. Do not use Java's ArrayList. We will discuss in class how to grow your array. Sample Text Input 6/3 7/3 6/3 12/6 Sample Console Output 6/3 has a count of 3 7/3 has a count of 1arrow_forwardFOR JAVA Write a method that takes an integer array, prints the elements that are divisible by 3 and returns the sum of these elements. Write a method that takes an integer array and returns the difference between the sum of even indexed elements and the sum of odd indexed elements in that array. Write a method that takes a String array and an integer as parameters and prints the Strings in the array whose length is greater than the second parameter. Write a method that takes two integer arrays, and returns a new array by taking the intersection of the two arrays.arrow_forwardWrite a program that defines symbolic constants for all seven days of the week. Create an arrayvariable that uses the symbols as initializers.arrow_forward
- Provide a different implementation of ChoiceQuestion. Instead of storing the choices in an array list, the addChoice method should add the choice to the question text. For this purpose, an addLine method has been added to the Question class. Use the following files: Question.java /** A question with a text and an answer.*/public class Question{ private String text; private String answer; /** Constructs a question with empty text and empty answer. */ public Question() { text = ""; answer = ""; } /** Sets the answer for this question. @param correctResponse the answer */ public void setAnswer(String correctResponse) { answer = correctResponse; } /** Checks a given response for correctness. @param response the response to check @return true if the response was correct, false otherwise */ public boolean checkAnswer(String response) { return response.equals(answer); } /** Add a line of text to…arrow_forwardWrite a Java Program that allows the user to enter an arbitrary number of integer grades from the keyboard. Each grade should be added to an ArrayList called grades. Stop inputting grades when -1 is entered. The program should then iterate through the ArrayList, calculate the average grade, and output it along with the minimum and the maximum grade value.arrow_forwardWrite a Java program that reads each line of an input file called data.txt that consists of a keyword followed by a sequence of numbers separated by commas and save it in arrayList. Then for each row in the arrayList check if the keyword is UP, the numbers are sorted in increasing order, if the key word is DOWN; the numbers are sorted in decreasing order. The sorted sequence of numbers is saved in sorted.txt. For example, if the data.txt contains UP: 25 35 30 40 30 DOWN : 20 30 25 25 DOWN: 35 45 40 15 16 18 The file sorted.txt will contain 25 30 30 35 40 30 25 25 20 45 40 35 18 16 15 Create class Sort to perform all sorting operations. The class also responsible of checking the validity of input file content. All input file records must follow the following format UP/down set of numbersarrow_forward
- Write a static method blur(double[][]picture) that you could use on a part of a picture file to obscure a detail such as a person’s face or a license plate number. This method computes the weighted averages of the values in picture and returns them in a new two-dimensional array. To find a weighted average of a group of numbers, you count some of them more than others. Thus, you multiply each item by its weight, add these products together, and divide the result by the sum of the weights. For each element in picture, compute the weighted average of the element and its immediate neighbors. Store the result in a new two dimensional array in the same position that the element occupies in picture. This new array is the one the method returns. The neighbors of an element in picture can be above, below, to the left of, and to the right of it, either vertically, horizontally, or diagonally. So each weighted average in the new array will be a combination of up to nine values from the array…arrow_forwardWrite a Java program that will allow the user to play a hangman game repeatedly until theychoose to stop. The game should randomly choose a secret word from a pre-set list of wordsfor the user to guess. Store the list of words available for play in an array so you can randomlychoose them by index during game play.During a turn, the user will guess one letter at a time. Each letter in the secret word shoulddisplay as an asterisk until the letter is guessed by the user. When a correct letter is guessed,the letter should be displayed in the correct position in place of the asterisk. The user hangshimself with the 8th wrong guess and loses the game.Make a character array to hold the characters and asterisks representing the word beingguessed. You can change the contents of this array as the letters are guessed and revealed. Inother words, this array can be used to display the current state of the secret word each round.Here is the list of words the game should choose from for the secret…arrow_forwardI'm trying to write a Java program that stores a text file of integer values into a 2D array. The integers in each column are separated by commas. I also want to print out the 2D array after it is created this is the text file: Input.text 15, 50, 62, 72, 73, 74 58, 60, 70, 73, 76, 82 43, 59, 65, 72, 82, 65 18, 42, 63, 69, 73, 85arrow_forward
- Image one is the example output of text-based histogram . Image 2 is my file. You can creat a new file too(up to u) as long as the output shows the times of appearances of the numbers. (Like the example showed in image 1, if number 20 appeared 1 times, print 1 star after it. I want to write: A method to print a text-based histogram takes one parameter, an array of integers no return valuearrow_forwardYou are given two int variables j and k, an int array zipcodeList that has been declared and initialized, and a boolean variable duplicates. Write some code that assigns true to duplicates if any two elements in the array have the same value, and that assigns false to duplicates otherwise. Use only j, k, zipcodeList, and duplicates. this is a java programarrow_forwardwrite a program (its name should be StudentPoll.java) that first reads an integer, N, for the number of responses from students and then creates an array of N elements of type int to store the responses. Use SecureRandom to generate N random integers of values between 3 and 10 inclusive as the response values (i.e., the survey values) for the array. The program should print out the distribution of the survey like the following outputs. public class StudentPoll {public static void main(String[] args) {// student response array (more typically, input at runtime)int[] responses = {1, 2, 5, 4, 3, 5, 2, 1, 3, 3, 1, 4, 3, 3, 3, 2, 3, 3, 2, 14};int[] frequency = new int[6]; // array of frequency counters // for each answer, select responses element and use that value// as frequency index to determine element to increment for (int answer = 0; answer < responses.length; answer++) { try { ++frequency[responses[answer]]; } catch (ArrayIndexOutOfBoundsException e) { System.out.println(e); //…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
Definition of Array; Author: Neso Academy;https://www.youtube.com/watch?v=55l-aZ7_F24;License: Standard Youtube License