Starting Out with Java: From Control Structures through Objects (6th Edition)
6th Edition
ISBN: 9780133957051
Author: Tony Gaddis
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 11, Problem 11AW
Assume that the reference variable r refers to a serializable object. Write code that serializes the object to the file ObjectData.dat.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
A file has r = 20, 000 STUDENT records of fixed length. Each record has the following fields: NAME (30 bytes), SSN (9 bytes), ADRESS(40 bytes), PHONE(9 bytes), BIRTHDATE (8 bytes), SEX(1 byte), CLASSCODE( 4 bytes, integer) MAJORDEPTCODE(4 bytes), MINORDEPTCODE(4 bytes), and DEGREEPROGRAM( 3 bytes). An additional byte is used as a deletion marker. Block size B = 512 bytes.
a) Calculate the blocking factor bfr (=floor(B/R), where R is the record size) and number of file blocks b, assuming unspanned organization (a record can’t be split across blocks).
b) Suppose only 80% of the STUDENT records have a value for PHONE, 85% for MAJORDEPTCODE, 15% for MINORDEPTCODE, and 90% for DEGREEPROGRAM. We use a variable-length record file. Each record has a 1-byte field type for each field in the record, plus the 1-byte deletion marker and a 1-byte end-of-record marker. Suppose that we use a spanned record organization, where each block has a 5-byte pointer to the next block (this space is not used…
Write the code segments based on the given descriptions:
Declare a file pointer called input. Open a file called location.txt for reading using this pointer.
If the file is not available, display “File does not exist.”.
The content of the text file location.txt is as shown below. It includes the location, latitude and longitude values.
FILE location.txt CONTENTS
<Location> <Latitude> <Longitude>
UTM 1.5523763 103.63322
KLCC 3.153889 101.71333
UM 3.1185 101.665
UMS 6.0367 116.1186
UNIMAS 1.465174 110.4270601
Ask the user to enter a location. Check if the user’s location can be found in the text file. If found, display the location, latitude and longitude as shown below.
SAMPLE OUTPUT
Enter a location: UM
Location : UM
Latitude : 3.1185
Longitude : 101.6650
Otherwise display “Sorry, location could not be found”.
SAMPLE OUTPUT
Enter a location : MMU
Sorry, location could not be found
A movie file has the following record structure:name ofthe movie producer director type productioncostAssume that the name of the movie is the primary key of the file. Thefield type refers to the type of the movie, for example, drama, sci-fi, horror, crimethriller, comedy and so forth. Input a sample set of records of your choice into themovie file.i) Implement a primary index-based ISAM file organization.ii) Implement secondary indexes on director, type and productioncost.
Chapter 11 Solutions
Starting Out with Java: From Control Structures through Objects (6th Edition)
Ch. 11.1 - Prob. 11.1CPCh. 11.1 - Prob. 11.2CPCh. 11.1 - Prob. 11.3CPCh. 11.1 - Prob. 11.4CPCh. 11.1 - Prob. 11.5CPCh. 11.1 - Prob. 11.6CPCh. 11.1 - Prob. 11.7CPCh. 11.1 - Prob. 11.8CPCh. 11.1 - Prob. 11.9CPCh. 11.1 - When does the code in a finally block execute?
Ch. 11.1 - What is the call stack? What is a stack trace?Ch. 11.1 - Prob. 11.12CPCh. 11.1 - Prob. 11.13CPCh. 11.1 - Prob. 11.14CPCh. 11.2 - What does the throw statement do?Ch. 11.2 - Prob. 11.16CPCh. 11.2 - Prob. 11.17CPCh. 11.2 - Prob. 11.18CPCh. 11.2 - Prob. 11.19CPCh. 11.3 - What is the difference between a text file and a...Ch. 11.3 - What classes do you use to write output to a...Ch. 11.3 - Prob. 11.22CPCh. 11.3 - What class do you use to work with random access...Ch. 11.3 - What are the two modes that a random access file...Ch. 11.3 - Prob. 11.25CPCh. 11 - Prob. 1MCCh. 11 - Prob. 2MCCh. 11 - Prob. 3MCCh. 11 - Prob. 4MCCh. 11 - FileNotFoundException inherits from __________. a....Ch. 11 - Prob. 6MCCh. 11 - Prob. 7MCCh. 11 - Prob. 8MCCh. 11 - Prob. 9MCCh. 11 - Prob. 10MCCh. 11 - Prob. 11MCCh. 11 - Prob. 12MCCh. 11 - Prob. 13MCCh. 11 - Prob. 14MCCh. 11 - Prob. 15MCCh. 11 - This is the process of converting an object to a...Ch. 11 - Prob. 17TFCh. 11 - Prob. 18TFCh. 11 - Prob. 19TFCh. 11 - True or False: You cannot have more than one catch...Ch. 11 - Prob. 21TFCh. 11 - Prob. 22TFCh. 11 - Prob. 23TFCh. 11 - Prob. 24TFCh. 11 - Find the error in each of the following code...Ch. 11 - // Assume inputFile references a Scanner object,...Ch. 11 - Prob. 3FTECh. 11 - Prob. 1AWCh. 11 - Prob. 2AWCh. 11 - Prob. 3AWCh. 11 - Prob. 4AWCh. 11 - Prob. 5AWCh. 11 - Prob. 6AWCh. 11 - The method getValueFromFile is public and returns...Ch. 11 - Prob. 8AWCh. 11 - Write a statement that creates an object that can...Ch. 11 - Write a statement that opens the file...Ch. 11 - Assume that the reference variable r refers to a...Ch. 11 - Prob. 1SACh. 11 - Prob. 2SACh. 11 - Prob. 3SACh. 11 - Prob. 4SACh. 11 - Prob. 5SACh. 11 - Prob. 6SACh. 11 - What types of objects can be thrown?Ch. 11 - Prob. 8SACh. 11 - Prob. 9SACh. 11 - Prob. 10SACh. 11 - What is the difference between a text file and a...Ch. 11 - What is the difference between a sequential access...Ch. 11 - What happens when you serialize an object? What...Ch. 11 - TestScores Class Write a class named TestScores....Ch. 11 - Prob. 2PCCh. 11 - Prob. 3PCCh. 11 - Prob. 4PCCh. 11 - Prob. 5PCCh. 11 - FileArray Class Design a class that has a static...Ch. 11 - File Encryption Filter File encryption is the...Ch. 11 - File Decryption Filter Write a program that...Ch. 11 - TestScores Modification for Serialization Modify...Ch. 11 - Prob. 10PC
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
Summarize the distinction between declarative statements and imperative statements.
Computer Science: An Overview (13th Edition) (What's New in Computer Science)
What is the advantage of using a sentinel?
Starting Out with Programming Logic and Design (5th Edition) (What's New in Computer Science)
What is the general problem with static scoping?
Concepts Of Programming Languages
Porter’s competitive forces model: The model is used to provide a general view about the firms, the competitors...
Management Information Systems: Managing The Digital Firm (16th Edition)
Determine the magnitude and direction of the resultant FR = F1 + F2 + F3 of the three forces by first finding t...
INTERNATIONAL EDITION---Engineering Mechanics: Statics, 14th edition (SI unit)
Add methods to the Person class from Self-Test Question 16 to perform the following tasks: Set the name attribu...
Java: An Introduction to Problem Solving and Programming (8th 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
- Put the class definition in EV.h and the implementation of the constructors and functions in EV.cpp 1. Define a class called "EV", that represents the information of an electric vehicle. The EV is defined with these attributes: model (string), range(int), unit (string) and year (int). Functions of the EV class must perform the following operations: 1. A default constructor which sets all the numeric instance variables to zero. 2. A constructor with 4 parameters which sets the 4 instance variables to the corresponding values passed. 3. Implement a getter function for each of the 4 instance variables that will return the value of the instance variable. For example, the getX() function for the instance variable model must be called getModel(). 4. Implement a setter function for each instance variable that will assign to the instance variable to the value passed. For example, the setX() function for the instance variable model must be called setModel(). 5. An info function: this function…arrow_forwardcomplete the top cpp file; ***Use a factory function to create objects; throws an invalid_argument if one of the elements would make the object invalid.arrow_forwardMilestone #1 - Ask Quiz Type In a file called main.py, implement a program that asks the user for a quiz type and prints the file name for that quiz type. The program should have one input prompt: the integer value of the personality quiz number. Your program should print the welcome message and the list of the personality quizzes, ask for the test number, and then print the file name. You are required to use the provided dictionary with the personality quizzes names. The list of the personality quizzes should be printed in alphabetical order. See example below. Welcome to the Personality Quiz! What type of Personality Quiz do you want to run? 1 BabyAnimals 2 Brooklyn99 3 Disney 4 Hogwarts 5 MyersBriggs 6 Sesame Street 7 - StarWars 8 - Vegetablesarrow_forward
- WAP to read 4 student objects and write them into a file, then print total number of student number in file. After that read an integer and print details of student stored at this number in the file using random access and file manipulators.arrow_forwardHow to code this assignment JSON objects. Hint: Work on the methods in the order they are found in the documentation below. def read_last_line(file_path: str)->str: """ Reads the last line of the file at the specified file path. The function returns the last line of the file as a string, if the file is empty it will return an empty string (""). :param file_path: A path to a file :return: The last line of the file """ def read(file_path: str)->str: """ Reads the entire file at the specified file path. The function returns all the text in the file as a string, if the file is empty it will return an empty string (""). :param file_path: A path to a file :return: All the text in the file """ def write(file_path:str, text:str=''): """ Clears the file at the specified file path then writes the specified line to the file. If the function is invoked without a line parameter or the line variable is None nothing is written to…arrow_forwardProgram is not run; error found in print(row) # Import the python CSV moduleimport csv# Create a python file object in read mode for the `baby_names.csv` file: csvfilecsvfile = open('baby_names.csv', 'r')# Loop over a DictReader on the filefor row in csv.DictReaderreader(csvfile): # Print each row print(row) # Add the rank and name to the dictionary: baby_names baby_names[row['RANK']] = row['NAME']# Print the dictionaryprint(baby_names.keys())arrow_forward
- Unix assignment Purpose: The purpose of this assignment is to use various concepts of the C Shell. 0. Change your default login shell to the C Shell. 1. Create a .cshrc file in your home directory that will do the following: * Create the alias (lsall) that will do all of the following: display the date, and a recursive long list of all files in a directory. * Create the alias (whoson) that will display the date and a sorted list of users logged in. * Declare the LOCAL variable that controls the size of your history list to the value 200. * Declare the shell variable that will cause the C Shell to send a message to your terminal whenever one of your background commands complete. 2. Create a .login file in your home directory to do the following. * Declare the GLOBAL Terminal Type variable to the value vt100. Display the value of the variable. Logout and log back in to make sure your .cshrc and .login files are automatically executed. Create a lab8.scr…arrow_forwardComputer sciencearrow_forward9b_act2. Please help me answer this in python programming.arrow_forward
- Q1: Write a Python program that prompt user to enter at least five entries: 1. Each entry requires two entities: Name (first, last) and Final Score (between 0 and 100) 2. saves the values in a text file 3. calculates the average for Final Score for all the entries written into the file 4. reads that text file and displays its contents on the command prompt including the score average. Write a Python program that prompts the user to search for a string( first and last name) from the file created in Q1. The program displays the name and the final score for that entry if that name was in the file.arrow_forwardWrite a function named repeat_words that takes two string parameters: 1. in_file: the name of an input file that exists before repeat_words is called 2. out_file: the name of an output file that repeat_words creates Assume that the input file is in the current working directory and write the output file to that directory. For each line of the input file, the function repeat_words should write to the output file all of the words that appear more than once on that line. Each word should be lower cased and stripped of leading and trailing punctuation. Each repeated word on a line should be written to the corresponding line of the output file only once, regardless of the number of times the word is repeated. For example, if the following is the content of the file catInTheHat.txt: Too wet to go out and too cold to play ball. So we sat in the house. We did nothing at all. So all we could do was to Sit! Sit! Sit! Sit! The following function call: inF = 'catInTheHat.txt' outF =…arrow_forwardIN PYTHON LANGUAGEarrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,Programming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
C - File I/O; Author: Tutorials Point (India) Ltd.;https://www.youtube.com/watch?v=cEfuwpbGi1k;License: Standard YouTube License, CC-BY
file handling functions in c | fprintf, fscanf, fread, fwrite |; Author: Education 4u;https://www.youtube.com/watch?v=aqeXS1bJihA;License: Standard Youtube License