Starting Out with Java: From Control Structures through Data Structures (3rd Edition)
3rd Edition
ISBN: 9780134038179
Author: Tony Gaddis, Godfrey Muganda
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
Chapter 7, Problem 18PC
Program Plan Intro
Phone Book ArrayList
Program Plan:
PhoneBookEntry.java:
- Declare the class “PhoneBookEntry”.
- Declare required variables.
- Define the constructor and set the values.
- Give mutator functions to set the name and phone number.
- Give accessor functions to get the name and phone number.
Main.java:
- Import required packages.
- Declare the class “Main”.
- Define the “main ()” method.
- Declare a variable.
- Create an array list to store the details.
- Loop from 0 through 5.
- Add the information by calling the function “get_Entry ()”.
- Print a line.
- Print all the details using “for” loop.
- Function definition for “get_Entry ()”.
- Get the persons’ name and phone number.
- Add the value to the object of the class.
- Return the object.
- Function definition to print the entry.
- Print the information using “getName ()” and “getPhoneNumber ()” methods.
- Define the “main ()” method.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Sultan Qaboos University
Department of Computer Science
COMP2202: Fundamentals of Object Oriented Programming
Assignment # 2 (Due 5 November 2022 @23:59)
The purpose of this assignment is to practice with java classes and objects, and arrays.
Create a NetBeans/IntelliJ project named HW2_YourId to develop a java program as explained below.
Important: Apply good programming practices:
1- Provide comments in your code.
2- Provide a program design
3-
Use meaningful variables and constant names.
4- Include your name, university id and section number as a comment at the beginning of your code.
5- Submit to Moodle the compressed file of your entire project (HW1_YourId).
1. Introduction:
In crowded cities, it's very crucial to provide enough parking spaces for vehicles. These are usually multistory
buildings where each floor is divided into rows and columns. Drivers can park their cars in exchange for some
fees. A single floor can be modeled as a two-dimensional array of rows and columns. A…
Java Program
Fleet class- reading from a file called deltafleet.txt-Using file and Scanner
Will be creating a file called newfleet.txt
Instance Variables:o An array that stores Aircraft that represents Delta Airlines entire fleeto A variable that represents the count for the number of aircraft in the fleet• Methods:o Constructor- One constructor that instantiates the array and sets the count to zeroo readFile()- This method accepts a string that represents the name of the file to beread. It will then read the file. Once the data is read, it should create an aircraft andthen pass the vehicle to the addAircraft method. It should not allow any duplicationof records. Be sure to handle all exceptions.o writeFile()- This method accepts a string that represents the name of the file to bewritten to and then writes the contents of the array to a file. This method shouldcall a sort method to sort the array before writing to it.o sortArray()- This method returns a sorted array. The array is…
Assignment 5C: Level Map Creator. There are a variety of ways that game developers store
their level layouts. One simple method is to associate level elements with certain symbols, and
then storing them in a 2D grid inside a text file. We will use our knowledge of 2D arrays to
create a very simple Level Map Creator tool.
The program should prompt the user to enter a width and height for the level. Then it should
initialize a 2D array and fill every element with the "*" symbol. Afterwards, the user should be
given the following options via a menu:
1. Clear Level
Re-initialize the 2D array and fill every element with the "*" symbol.
2. Add Platform
Prompt the user to enter a starting point and length for the
horizontal platform. Replace those elements in the 2D array with
the "=" symbol. If the length is longer than the number of columns
(or out of bounds), notify the user that this is not possible.
3. Add Item
Prompt the user to enter a column and row index. Replace that
element in the…
Chapter 7 Solutions
Starting Out with Java: From Control Structures through Data Structures (3rd Edition)
Ch. 7.1 - Write statements that create the following arrays:...Ch. 7.1 - Whats wrong with the following array declarations?...Ch. 7.1 - Prob. 7.3CPCh. 7.1 - Prob. 7.4CPCh. 7.1 - Prob. 7.5CPCh. 7.1 - Prob. 7.6CPCh. 7.1 - Prob. 7.7CPCh. 7.1 - Prob. 7.8CPCh. 7.2 - Prob. 7.9CPCh. 7.2 - Prob. 7.10CP
Ch. 7.2 - A program has the following declaration: double[]...Ch. 7.2 - Look at the following statements: int[] a = { 1,...Ch. 7.3 - Prob. 7.13CPCh. 7.3 - Write a method named zero, which accepts an int...Ch. 7.6 - Prob. 7.15CPCh. 7.7 - Recall that we discussed a Rectangle class in...Ch. 7.10 - Prob. 7.17CPCh. 7.11 - What value in an array does the selection sort...Ch. 7.11 - How many times will the selection sort swap the...Ch. 7.11 - Prob. 7.20CPCh. 7.11 - Prob. 7.21CPCh. 7.11 - If a sequential search is performed on an array,...Ch. 7.13 - What import statement must you include in your...Ch. 7.13 - Write a statement that creates an ArrayList object...Ch. 7.13 - Write a statement that creates an ArrayList object...Ch. 7.13 - Prob. 7.26CPCh. 7.13 - Prob. 7.27CPCh. 7.13 - Prob. 7.28CPCh. 7.13 - Prob. 7.29CPCh. 7.13 - Prob. 7.30CPCh. 7.13 - Prob. 7.31CPCh. 7 - Prob. 1MCCh. 7 - Prob. 2MCCh. 7 - Prob. 3MCCh. 7 - Prob. 4MCCh. 7 - Array bounds checking happens. a. when the program...Ch. 7 - Prob. 6MCCh. 7 - Prob. 7MCCh. 7 - Prob. 8MCCh. 7 - Prob. 9MCCh. 7 - Prob. 10MCCh. 7 - Prob. 11MCCh. 7 - To delete an item from an ArrayList object, you...Ch. 7 - Prob. 13MCCh. 7 - Prob. 14TFCh. 7 - Prob. 15TFCh. 7 - Prob. 16TFCh. 7 - Prob. 17TFCh. 7 - Prob. 18TFCh. 7 - True or False: The Java compiler does not display...Ch. 7 - Prob. 20TFCh. 7 - True or False: The first size declarator in the...Ch. 7 - Prob. 22TFCh. 7 - Prob. 23TFCh. 7 - int[] collection = new int[-20];Ch. 7 - Prob. 2FTECh. 7 - Prob. 3FTECh. 7 - Prob. 4FTECh. 7 - Prob. 5FTECh. 7 - Prob. 1AWCh. 7 - Prob. 2AWCh. 7 - Prob. 3AWCh. 7 - In a program you need to store the populations of...Ch. 7 - In a program you need to store the identification...Ch. 7 - Prob. 6AWCh. 7 - Prob. 7AWCh. 7 - Prob. 8AWCh. 7 - Prob. 9AWCh. 7 - Prob. 10AWCh. 7 - Prob. 11AWCh. 7 - Prob. 1SACh. 7 - Prob. 2SACh. 7 - Prob. 3SACh. 7 - Prob. 4SACh. 7 - Prob. 5SACh. 7 - Prob. 6SACh. 7 - Prob. 7SACh. 7 - Prob. 8SACh. 7 - Prob. 9SACh. 7 - Rainfall Class Write a RainFall class that stores...Ch. 7 - Payroll Class Write a Payroll class that uses the...Ch. 7 - Charge Account Validation Create a class with a...Ch. 7 - Charge Account Modification Modify the charge...Ch. 7 - Prob. 5PCCh. 7 - Drivers License Exam The local Drivers License...Ch. 7 - Magic 8 Ball Write a program that simulates a...Ch. 7 - Grade Book A teacher has five students who have...Ch. 7 - Grade Book Modification Modify the grade book...Ch. 7 - Average Steps Taken A Personal Fitness Tracker is...Ch. 7 - Array Operations Write a program with an array...Ch. 7 - 12.1994 Gas Prices In the student sample programs...Ch. 7 - Sorted List of 1994 Gas Prices Note: This...Ch. 7 - Name Search If you have downloaded this books...Ch. 7 - Population Data If you have downloaded this books...Ch. 7 - World Series Champions If you have downloaded this...Ch. 7 - 2D Array Operations Write a program that creates a...Ch. 7 - Prob. 18PCCh. 7 - Trivia Game In this programming challenge, you...Ch. 7 - Prob. 20PC
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
- In previous chapters, you have created programs for the Greenville Idol competition. Now create a Contestant class with the following characteristics: The Contestant class contains public static arrays that hold talent codes and descriptions. Recall that the talent categories are Singing Dancing, Musical instrument, and Other. The class contains an auto-implemented property that holds a contestants name. The class contains fields for a talent code and description. The set accessor for the code assigns a code only if it is valid. Otherwise, it assigns I for Invalid. The talent description is a read-only property that is assigned a value when the code is set. Modify the GreenvilleRevenue program so that it uses the Contestant class and performs the following tasks: The program prompts the user for the number of contestants in this years competition; the number must be between 0 and 30. The program continues to prompt the user until a valid value is entered. The expected revenue is calculated and displayed. The revenue is $25 per contestant. The program prompts the user for names and talent codes for each contestant entered. Along with the prompt for a talent code, display a list of the valid categories. After data entry is complete, the program displays the valid talent categories and then continuously prompts the user for talent codes and displays the names of all contestants in the category. Appropriate messages are displayed if the entered code is not a character or a valid code.arrow_forwardProject 5 - Magic Squares Objectives The objective of this project is to have students practice with two-dimensional arrays and loops. Specifications In this project, you will write code to determine if a two-dimensional array of ints is a Magic Square. For a two- dimensional array of ints to be a Magic Square all of the following must be true: 1. The array must be square - in other words, the lengths of all rows and all columns must be the same. 2. The array must contain all integers from 1 to n*n, where n is the length of the rows and columns. 3. The sum of the numbers in each diagonal, each row, and each column must be the same. You have been given two classes: • MagicSquareTest.java - Contains JUnit test cases for the MagicSquare class. Your code must pass all these tests. • MagicSquare.java - contains static methods to determine if a two-dimensional array of ints is a Magic Square: o isMagicSquare() - returns true if a two-dimensional array of ints meets all the criteria to be a…arrow_forwardAssignment 5C: Level Map Creator. There are a variety of ways that game developers store their level layouts. One simple method is to associate level elements with certain symbols, and then storing them in a 2D grid inside a text file. We will use our knowledge of 2D arrays to create a very simple Level Map Creator tool. The program should prompt the user to enter a width and height for the level. Then it should initialize a 2D array and fill every element with the *" symbol. Afterwards, the user should be given the following options via a menu: 1. Clear Level 2. Add Platform Prompt the user to enter a starting point and length for the Re-initialize the 2D array and fill every element with the "** symbol. horizontal platform. Replace those elements in the 2D array with the "=" symbol. If the length is longer than the number of columns |(or out of bounds), notify the user that this is not possible. Prompt the user to enter a column and row index. Replace that element in the 2D array…arrow_forward
- Design an application that declares an array of 20 AutomobileLoan objects. Prompt the user for data for each object, and then display all the values.arrow_forwardHomework - identical arrays for one-dimensional: Write a test program which prompts a user to enter the size of two arrays as well as to fill their elements. After that, the program checks the same contents of the elements of the two arrays. If these arrays are equal, the program displays message which is "The two arrays are identical". If not equal, displaying "The two arrays are not identical". Write an equals method that reads two arrays and displays these messages above.arrow_forwardBasic javaarrow_forward
- Increasing the length property value adds extra items to an array, but the elements are null until they are declared. Is it true or falsearrow_forwardFor each object class include the following: displayPromotion () method which can be used to display the following messages:Video Game: Only certain of video game will be getting 10% discount.Sport Game: Booking court on week days will be getting 15% discount.Overridden toString() method that returns a string containing all the data fields’values.(photo 111) Write a driver program that uses a polymorphic array to store information for various video games and sport games. Use an array initializer to initialize the array with values. Then, display a list with all the game information. A sample output is provided below:(photo 112)arrow_forwardLab Goal : This lab was designed to teach you how to use an array. Lab Description : Take a list of numbers that range in value from 0 to 9 and output how many occurrences of each number exist.arrow_forward
- Declare and initialize 2 Animal objects with the following properties: A animal named Zirly the Zebra with the zebraZirlyBehaviors created above and a weight of 812.3 pounds A animal named Henry the Hawk with the henryTheHawkBehaviors created above and a weight of 35.5 pounds. Then, store the 2 animal objects in an array named animalList Choose one of the following from the above choices (A, B, C or D within the code). // Assume the following constructor exists within the Animal class: public Animal(String animalName, double weight, Behavior[] behaviorList) { this.animalName = animalName; this.weight = weight; this.behaviorList = behaviorList; } //A Animal zebraZirly = new Animal(812.3, "Zirly the Zebra", zebraZirlyBehaviors); Animal henryTheHawk = new Animal(35.5, "Henry the Hawk", henryTheHawkBehaviors); Animal[] animalList = new Animal[]{zebraZirly, henryTheHawk}; // B Animal zebraZirly = new Animal("Zirly the Zebra", 812.3,…arrow_forwardQUESTIONS- 1. Create and array of objects named movies . Each of the objects in the array will represent a movie.Each object should have properties for:movie titlerelease yearrating (your rating 1 - 10)genres (an array of genres. eg ["Drama", "Mystery", "Sci-Fi", "Western"] )The array should contain at least 5 of movies you have seen (choose your own movies)You do not need to use JSON to create this arrayYou can use IMDB if you need help finding the info for your movie2. Now that digital format is taking over, we would like to add a property to each object for the format (“film” or“digital”). The property will be called format . Assuming that all movies in our data set where shot on film, use.forEach() to add the property and set a value of “film” for each movie.3. Use the .map() method to create an array of movie titles from our initial data set named movieTitles .4. Use the .reduce() method to find the highest and lowest rated movies in the data set. Store these objects invariables…arrow_forwardWrite code for PersonManagement class. This class contains the array of Person class (code is given below) and also following methods: set: This method receives the array of person class and set the attribute. displayAll: This method will display values of all persons. sort: This method will sort the array according to age values of the persons with ascending order using Selection Sort. reverse: This method will reverse the order of the array. getPersons: This method will return the array of the persons (attribute). displayEvenAgePerson: This method will display all those persons values who have even age. displayOddAgePerson: This method will display all those persons values who have odd age. displayPrimeAgePerson: This method will display only those persons values who have prime number age. Following is the class of Person: public class Person { private String Name; public int age; public void set(String Name, int age) { this.Name =…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Programming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:CengageEBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTMicrosoft Visual C#Computer ScienceISBN:9781337102100Author: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
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,