Concept explainers
Solution to
In this project you are to create a
Select from the following choices: 1. Add new book 2. Print listing sorted by author 3. Quit 1 Enter title: More Than Human Enter author: Sturgeon, Theodore Enter date: 1953 Select from the following choices: 1. Add new book 2. Print listing sorted by author 3. Quit 1 Enter title: Problem Solving with C++ Enter author: Savitch, Walter Enter date: 2015 Select from the following choices: 1. Add new book 2. Print listing sorted by author 3. Quit 2 The books entered so far, sorted alphabetically by author are: Savitch, Walter. Problem Solving with C++. 2015. Sturgeon, Theodore. More Than Human. 1953. Select from the following choices: 1. Add new book 2. Print listing sorted by author 3. Quit 1 Enter title: At Home in the Universe Enter author: Kauffman Enter date: 1996 Select from the following choices: 1. Add new book 2. Print listing sorted by author 3. Quit 2 The books entered so far, sorted alphabetically by artist are: Kauffman, At Home in the Universe, 1996 Savitch, Walter. Problem Solving with C++. 2015. Sturgeon, Theodore. More Than Human. 1953. |
Want to see the full answer?
Check out a sample textbook solutionChapter 18 Solutions
Problem Solving with C++ (10th Edition)
Additional Engineering Textbook Solutions
C How to Program (8th Edition)
Starting Out With Visual Basic (7th Edition)
Starting Out with Python (3rd Edition)
Modern Database Management
Starting Out with C++ from Control Structures to Objects (9th Edition)
Database Concepts (7th Edition)
- Write a Java program that prompts a user for vehicle data and stores it in a linked list, and then sorts the list in ascending order based on miles-per-gallon and writes the sorted data to a text file, you can follow these steps: Create a class named Vehicle with private fields: make (String), model (String), and milesPerGallon (double). Include getters and setters for these fields. Implement the Comparable interface for Vehicle class and override the compareTo() method to compare vehicles based on their milesPerGallon. Create a main class (for example, VehicleDriver.java) to handle user input and perform the necessary operations. Inside the main method, create a BufferedReader object for user input. Prompt the user to enter the number of vehicle data they want to enter and store it in a variable (for example, nVehicles). Use a loop to iterate nVehicles times and prompt the user to enter make, model, and miles per gallon for each vehicle. Create Vehicle objects using the input data…arrow_forwardI already have the code for the assignment below, but there is some errors in the code. Please help me fix them. The assignment: Make a telephone lookup program. Read a data set of 1,000 names and telephone numbers from a file that contains the numbers in random order. Handle lookups by name and also reverse lookups by phone number. Use a binary search for both lookups. This assignment needs a resource class and a driver class. The resource class and the driver class will be in two separate files. The resource class will contain all of the methods and the driver class only needs to call the methods. The driver class needs to have only 5 lines of code. The code needs to be written in Java. Please help me with exactly what I asked for help. The code: PhoneLookup.java import java.io.FileReader;import java.io.IOException;import java.util.Scanner; public class PhoneLookup{ public static void main(String[] args) throws IOException { Scanner in = new Scanner(System.in);…arrow_forwardWrite a program in C++ that reads a list of 10 names from a file and stores them in an array. Next, allow the user to search for the number of instances of a name. The program should prompt a user for a name and output the total number of instances of that name entered to the screen and to a file (see example input and output below). It should continue to prompt for names until the word done is typed in. For this lab, use the string data type as opposed to char to store the names (i.e. don’t use c-strings). INPUT FILEJoe Sally Joe Sue Sally Adam Joe Adam Adam Joe OUTPUT FILE (There should be 10 spaces between the columns) 8. NAME INSTANCES 9. ---- --------- 10. Joe 4 11. Sally 2 12. Adam 3 13. Sue 1 14. John - Expected outputarrow_forward
- Write a program in C++ that reads a list of 10 names from a file and stores them in an array. Next, allow the user to search for the number of instances of a name. The program should prompt a user for a name and output the total number of instances of that name entered to the screen and to a file (see example input and output below). It should continue to prompt for names until the word done is typed in. For this lab, use the string data type as opposed to char to store the names (i.e. don’t use c-strings). Input FileJoeSallyJoeSueSallyAdamJoeAdamAdamJoe Output File (be sure to output the class heading to the output file) (There should be 10 spaces between the columns) 8. NAME INSTANCES9. ---- --------- 10. Joe 411. Sally 212. Adam 313. Sue 114. John - Expected output in image belowarrow_forwardAt the end of this and other textbooks, there usually is an index that lists the pages where a certain word appears. In this problem, you will create an index for a text but, instead of page number, you will use the line numbers. You will implement function index() that takes as input the name of a text file and a list of words. For every word in the list, your function will find the lines in the text file where the word occurs and print the corresponding line numbers (where the numbering starts at 1). You should open and read the file only once Create the python function as part of a python program. The data required for the function should be created in the python program and passed to the function. its an exercise pyrthon problem 6.27arrow_forwardWrite a Java program that simulates a basic library delivery system. The user of the program will beable to add different types of items to library collection. In your program, as the main data structure,use the generic collection class ArrayList to store String references.Create three instances from ArrayList of String references. The first one will store the types, thesecond one will store the items, and the third one will store the owners of the items. The types areexactly the following: "Book", "DVD", "Magazine". The items and their owners will be read fromthe keyboard.Regarding the matching between an item and its owner, the location (index value) of an item in thelist of items will be the same with the location of its corresponding owner in the list of owners.As the next step, create the fourth instance from ArrayList of String references and call this list asitemsDeliveredByOwners. This last list will store String references to indicate the owners ofthe items (such as the…arrow_forward
- Write a program that inputs, processes, and outputs a set of student records organized as a vector of structure StudentRec objects. write a program where each student record is a structure that looks like this: struct StudentRec { string last_name = ""; // Last name string first_name = ""; // First name int year_grad = 0; // Year expected to graduate float gpa = 0.0; // Current gpa } The program should ask for the data to fill a studentRec of structure StudentRec and then ask y/n if they want to add another studentRec. Each studentRec will go into the vector of type StudentRec called student_list. After the student records have been entered into the vector student_list, find the average gpa of all the students in the vector. Output all the student records and give the average gpa for the students. Use the iomanip tools to make the data look as nice a possible. Write excellent comments: Critical or tricky parts that might…arrow_forward• Your program reads one text file:– input.txt• Your program creates a text file:– output.txt• Your program solves the following problem:– You are given a water level information L. Condition: 0<L<128.– You are given a terrain information (elevation matrix M). Condition: 0M[i][j]<128 8i,j<512.– Definition of an island: An island is the collection of terrain points( elevation values M[i][j]), abovewater( greater than L value), from which you can find a path to any other without having to pass thepath through water.– Definition of a path: A path is an ordered set of points where successive points have either their Xcoordinates the same and their Y coordinates different only by one in magnitude (so can be y - 1 or y +1); or have their Y coordinates the same and have their X coordinates different only by one in magnitude(so can be x - 1 or x + 1). But not both of them: in other words they have to touch either in the Xdirection or in the Y direction, and not in the diagonal.–…arrow_forwardYou will write a program to process the lines in a text file using a linked list ADT and raw pointers. Node class You will create a class “Node” with the following private data attributes: line – line from a file (string) next - (pointer to a Node) Put your class definition in a header file and the implementation of the methods in a .cpp file. Follow the style they use in the book of having a "#include" for the implementation file at the bottom of the header file. You will have the following public methods: Accessors and mutators for each attribute Constructor that initializes the attributes to nulls (empty string and nullptr) LinkedList class You will create a class “LinkedList” with the following private data attributes: headPtr – raw pointer to the head of the list numItems – number of items in the list Put your class definition in a header file and the implementation of the methods in a .cpp file. Follow the style they use in the book of having a "#include" for the…arrow_forward
- Write a program that simulates a Magic 8-Ball. Prompt the user for a question, and randomly select a response from a vector. The attached Responses file is available if you want to use it, OR you may create your own response file, OR you can add/modify/remove the responses in the attached file. Continue to prompt for questions until the user wants to exit the program (Pick your own exit condition, but the program must loop until the condition is met!). Additional requirements: Header comments must be present Prototypes must be present if functions are used Hello and goodbye messages must be shown Use vector(s) for implementation Use comments and good style practices HINT: Read the contents of the response file into an a vector. When the user enters a question, generate a random index and display the response from the vector with that index. Make sure to check for the exit condition. To generate the random index, use the following in main() - this should be familiar by now...unsigned…arrow_forwardA) Write a program and define a class of Student. Student has these attributes :Age (an int)FirstName (a string)LastName (a string)Social Security Number (an int)Add the default constructor Add a second constructor that sets the attributes of the class Add the copy constructor that creates a copy of the student and override assignment operator. B) Create a vector of 100 students. Use a for loop to fill the vector . C) Add a function to your program that sorts the vector using selection sort in ascending order . D) Add a function to your program that searches the vector using binary search to find the youngest student .arrow_forwardwhen analyzing data sests such as data for human heights or for human weights a common step is to adjust the data this adjustment can be done by normalizing two values between 0 and 1. write a code block that reads(from user input) a list of 5 numbers and stores them in a vector of doubles. then, the block adjusts the values by dividing all of them, by the largest value. output each floating point value with two digits after the decimal point, which can be acheived by execeuting cout << fixed << setprecision(2); once before all other cout statement.arrow_forward
- 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