EBK JAVA PROGRAMMING
9th Edition
ISBN: 9781337671385
Author: FARRELL
Publisher: CENGAGE LEARNING - CONSIGNMENT
expand_more
expand_more
format_list_bulleted
Expert Solution & Answer
Chapter 3, Problem 18RQ
Program Description Answer
Before storing data in the object myJournal memory should be allocated for it explicitly.
Hence, the correct answer is option “A”.
Expert Solution & Answer
Trending nowThis is a popular solution!
Students have asked these similar questions
Introduction
In this project, you will complete a C++ class by writing a copy constructor, destructor, and assignment
operator. Furthermore, you will write a tester class and a test program and use Valgrind to check that
your program is free of memory leaks. Finally, you will submit your project files on GL. If you have
submitted programs on GL using shared directories (instead of the submit command), then the
submission steps should be familiar.
In this project we develop an application which holds the information about a digital art piece. There
are two classes in this project.
• The Random class generates data. The implementation of this class is provided. It generates
random int numbers for colors. To create an object of this class we need to specify min and max
values for the constructor. The colors fall between 30 and 37 inclusively.
The Art class generates random colors and stores the color values. You implement the Art class.
An object of the Art class is a digital masterpiece.…
Q3: You are designing a program for storing information about Computers. There are different
types of computer for different purposes. Create a class Computer which will have attributes:
CPUName=string, CPUClockSpeed_ghz-float, memory_gb3float. Now derive two classes from
the Computer class, PC which will have attributes: operatingSystem3string, model=int,
hasGPU=boolean and second class will be Smartphone which will have attributes:
OSversion=string, battery_mAH=int. Write following functions for each class:
> Constructor/Destructor
> Deep Copy Constructor
Parameterised Constructor
Getter/Setter for dimension and length/radius
Function to write the information to data file in append mode.
Write a main function to create a dynamic array of PC and smartphone.
Also write a function to get the PC with max CPUClockSpeed_ghz.
Note: Write those functions which are asked. Be Precise in your answer.
An n-sided regular polygon’s sides all have the same length and all of its angles have the same degree (i.e., the polygon is both equilateral and equiangular). Design a class named RegularPolygon thatcontains:■ A private int data field named n that defines the number of sides in the polygon.■ A private float data field named side that stores the length of the side.■ A private float data field named x that defines the x-coordinate of the center of the polygon with default value 0.
■ A private float data field named y that defines the y-coordinate of the center of the polygon with default value 0.■ A constructor that creates a regular polygon with the specified n (default 3),side (default 1), x (default 0), and y (default 0).■ The accessor and mutator methods for all data fields.■ The method getPerimeter() that returns the perimeter of the polygon.■ The method getArea() that returns the area of the polygon. The formula for computing the area of a regular polygon is Area = (n * s2) / (4 *…
Chapter 3 Solutions
EBK JAVA PROGRAMMING
Ch. 3 - Prob. 1RQCh. 3 - Prob. 2RQCh. 3 - Prob. 3RQCh. 3 - Prob. 4RQCh. 3 - Prob. 5RQCh. 3 - Prob. 6RQCh. 3 - Prob. 7RQCh. 3 - Prob. 8RQCh. 3 - Prob. 9RQCh. 3 - Prob. 10RQ
Ch. 3 - Prob. 11RQCh. 3 - Prob. 12RQCh. 3 - Prob. 13RQCh. 3 - Prob. 14RQCh. 3 - Prob. 15RQCh. 3 - Prob. 16RQCh. 3 - Prob. 17RQCh. 3 - Prob. 18RQCh. 3 - Prob. 19RQCh. 3 - Prob. 20RQCh. 3 - Prob. 1PECh. 3 - Prob. 2PECh. 3 - Prob. 3PECh. 3 - Prob. 4PECh. 3 - Prob. 5PECh. 3 - Prob. 6PECh. 3 - Prob. 7PECh. 3 - Prob. 8PECh. 3 - Prob. 9PECh. 3 - Prob. 10PECh. 3 - Prob. 11PECh. 3 - Prob. 12PECh. 3 - Prob. 13PECh. 3 - Prob. 1GZCh. 3 - Prob. 2GZCh. 3 - Prob. 1CP
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
- design a Club class and use it to create an application that simulates asoccer league tournament. You are not limited to the features included in these instructionsDesign the Club class, to be used in your application, containing: A private data member code of type string that holds the three letters club’s abbreviation(ex, FCB, LIV, RAM ...) A private data member name of type string that holds the club’s name (ex, FC Barcelona,Liverpool, Real Madrid …) A private data member round of type integer that holds the number of rounds the club hasplayed so far in the current league. A private data member wins of type integer that holds the number of times the club haswon in the current league. A private data member draws of type integer that holds the number of times the club hasbeen drawn in the current league. A private data member losses of type integer that holds the number of times the club haslost in the current league. A private data member goals of type integer that holds the…arrow_forwardThere is a class team ,that holds information about the team name, number of players in the team,and player's code.design the constructor function that decides the number of player in the team and intializes code for each player.create a team and display it's all data.( Implement dynamic memory allocation).arrow_forwardMissing line of code pleasearrow_forward
- In Python: Write a class named Pet, which should have the following data attributes: _ _name (for the name of a pet) _ _animal_type (for the type of animal that a pet is. Example values are 'Dog','Cat', and 'Bird') _ _age (for the pets age) The Pet class should have an _ _init_ _ method that creates these attributes. It should also have the following methods: set_nameThis method assigns a value to the _ _name field set_animal_typeThis method assigns a value to the _ _animal_type field set_ageThis method assignsa value to the _ _age field get_nameThis method assignsa value to the _ _name field get_animal_typeThis method assignsa value to the _ _animal_type field get_ageThis method assignsa value to the _ _age field Once you have written the class, write a program that creates an object of the class and prompts the user to enter the name, type and age of his or her pet. This data should be stored as the objects attributes. Use the objects accessor methods to retrieve the pets…arrow_forwardThis program is based in Java, so the response has to be java. Movie Collection Program Create a program that keeps track of your movie collection. Your driver file is movieCollection You will use it to create 4 movie objects. Your Movie class should have a default constructor that does not receive any values and sets all information to default values. You should also have an overload constructor method that has all of the data passed into it. The following information is what each movie object should have: Title Genre Year of release Director. You should have mutator methods that let you set all pieces of information individually. You should have accessor methods that allow you to get each piece of information individually. You should have a toString method that prints out all of the information about a movie at one time. Each piece of information should be on its own line. In the movieCollection file Movie one should be created using the default constructor.…arrow_forwardDesign a class named StopWatch. The class contains:■ The private data fields startTime and endTime with get methods.■ A constructor that initializes startTime with the current time.■ A method named start() that resets the startTime to the current time.■ A method named stop() that sets the endTime to the current time.■ A method named getElapsedTime() that returns the elapsed time for thestop watch in milliseconds.Draw the UML diagram for the class, and then implement the class. Write a test program that measures the execution time of adding numbers from 1 to 1,000,000.arrow_forward
- 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_forwardclass Student(object): """Represents a student.""" def __init__(self, name, number): """All scores are initially 0.""" self._name = name self._scores = [] for count in range(number): self._scores.append(0) def getName(self): """Returns the student's name.""" return self._name def setScore(self, i, score): """Resets the ith score, counting from 1.""" self._scores[i - 1] = score def getScore(self, i): """Returns the ith score, counting from 1.""" return self._scores[i - 1] def getAverage(self): """Returns the average score.""" return sum(self._scores) / len(self._scores) def getHighScore(self): """Returns the highest score.""" return max(self._scores) def __str__(self): """Returns the string representation of the student.""" return "Name: " + self._name + "\nScores: " + \ " ".join(map(str, self._scores))arrow_forwardThe _______________operator dynamically allocates memory for an object of a specified typeand returns a(n)______________ to that typearrow_forward
- If we do not override the toString method in a class, the toString method for the Object is called. The default output is <class name>@<memory location>. True Falsearrow_forwardCompilation error Main. java:16: error: incompatible types: char[][] cannot be converted to char[] String string - String.copyValuedf(grid): Main. java:39: error: constructor CharGrid in class CharGrid cannot be applied to given types; grid- new CharGrid(nunRows, numCols); required: int, int, char found: int, nt reason: actual and formal argunent lists differ in lenath Note: Some messages have been simplified; recompile with-Xdiags:verbose to get full output 2 errors Hide Time limit: 8 seconds Memory limit: 256 MB 1// YOUR CODE HERE 2 class CharGrid( 3 private char[]] grid; 4. public CharGrid(int nunRows, int nunCols, char symbol){ 61 for (int i 0; 1< numRows: i++){ for (int j e; j< numCols; j++)( grid[i][j]- symbol; 8 10 11 12 13 String string String.copyValueof (grid): 14 15 C0verride 16 public String tostring() ( 17 return string: 18 19) 20 21 22 23 Submit Start over (reset)arrow_forwardCreate a class called Person that will hold information about a single individual. This class should have a data section that consists of the following: Variable Name Data Type firstName string lastName string address string The Person class should have the following mutators: setFirstName(string first); setLastName(string last); setAddress(string address); The Person class should have the following accessors: string getFirstName(); string getLastName(); string getAddress(); The Person class should have the following constructors: Person(); - default Person(string first, string last); - Set other fields to an empty string Person(string first, string last, string address); Note: You must use delegating constructors to eliminate duplicate code. Main Create an array which will hold 5 Person classes. Pass the array to a function called getPeople which will fill out the array with information about people taken from the keyboard. Create a…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,
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,
Memory Management Tutorial in Java | Java Stack vs Heap | Java Training | Edureka; Author: edureka!;https://www.youtube.com/watch?v=fM8yj93X80s;License: Standard YouTube License, CC-BY