Starting Out with Java: From Control Structures through Objects (7th Edition) (What's New in Computer Science)
7th Edition
ISBN: 9780134802213
Author: Tony Gaddis
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 6.3, Problem 6.17CP
Assume that r1 and r2 are variables that reference Rectangl e objects, and the following statements are executed:
r1.setLength(5.0);
r2.setLength(10.0);
r1.setWidth(20.0);
r2.setWidth(15.0);
Fill in the boxes in Figure 6-21 that represent each object’s length and width fields.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
OOP1 - Objects, Classes, and Encapsulation
Create a program that has the following method and corresponding usage.
1. PerimeterTriangle - compute the perimeter of a triangle
1. Write JavaScript function that will serve as a constructor for Rectangle object with two data properties width and length. Add method to the rectangle object that will compute and return the area of the rectangle. 2. Write Javascript function that will take as an input a string and check if that string contains letters a, b, c (disregarding case) in order but not necessarily adjacent. The function should return either true or false and needs to use regular expressions. here are some examples of strings that should return true:
abc
danmhblkoc
aabbc
adagbkbiuc
abca
And, here are some strings that should return false:
dgk
dakl
cba
abac.
Create an object prototype called Gradebook that will pass an array of grades for a student as a parameter.
- Create a boolean in Gradebook madeHonourRoll that will check whether or not the student has made honour roll
- Create a function within Gradebook, that will calculate the average of the grades passed
- Create a function outside of Gradebook, that will check if the grades are over an 80% average. Return madeHonourRoll as true if the student has made over 80% average.
- Create a function outside Gradebook, called toString(), that will output to console whether or not the student has made the honour roll.
Chapter 6 Solutions
Starting Out with Java: From Control Structures through Objects (7th Edition) (What's New in Computer Science)
Ch. 6.1 - What does an object use its fields for?Ch. 6.1 - Prob. 6.2CPCh. 6.1 - How is a class like a blueprint?Ch. 6.1 - You have programs that create Scanner, Random, and...Ch. 6.1 - Prob. 6.5CPCh. 6.1 - What values do reference variables hold?Ch. 6.1 - Prob. 6.7CPCh. 6.2 - You hear someone make the following comment: A...Ch. 6.2 - Prob. 6.9CPCh. 6.2 - When a variable is said to reference an object,...
Ch. 6.2 - Prob. 6.11CPCh. 6.2 - Prob. 6.12CPCh. 6.2 - Prob. 6.13CPCh. 6.2 - Prob. 6.14CPCh. 6.2 - Prob. 6.15CPCh. 6.2 - What is a stale data item?Ch. 6.3 - Assume that r1 and r2 are variables that reference...Ch. 6.4 - How is a constructor named?Ch. 6.4 - What is a constructors return type?Ch. 6.4 - Prob. 6.20CPCh. 6.7 - Prob. 6.21CPCh. 6.7 - What is a methods signature?Ch. 6.7 - Look at the following class: public class...Ch. 6.7 - How many default constructors may a class have?Ch. 6.9 - Prob. 6.25CPCh. 6.9 - When designing an object-oriented application, who...Ch. 6.9 - How do you identify the potential classes in a...Ch. 6.9 - What are a classs responsibilities?Ch. 6.9 - What two questions should you ask to determine a...Ch. 6.9 - Will all of a classs actions always be directly...Ch. 6 - This is a collection of programming statements...Ch. 6 - A class is analogous to a(n) _______. a. house b....Ch. 6 - An object is a(n) ________. a. blueprint b....Ch. 6 - This is a class member that holds data. a. method...Ch. 6 - This key word causes an object to be created in...Ch. 6 - This is a method that gets a value from a classs...Ch. 6 - This is a method that stores a value in a field or...Ch. 6 - When the value of an item is dependent on other...Ch. 6 - This is a method that is automatically called when...Ch. 6 - When a local variable has the same name as a...Ch. 6 - This is automatically provided for a class if you...Ch. 6 - Prob. 12MCCh. 6 - Prob. 13MCCh. 6 - A classs responsibilities are __________. a. the...Ch. 6 - True or False: The new operator creates an...Ch. 6 - True or False: Each instance of a class has its...Ch. 6 - True or False: When you write a constructor for a...Ch. 6 - True or False: A class may not have more than one...Ch. 6 - True or False: To find the classes needed for an...Ch. 6 - Find the error in the following class: public...Ch. 6 - Prob. 2FTECh. 6 - The following statement attempts to create a...Ch. 6 - Find the error in the following class: public...Ch. 6 - Find the error in the following class: public...Ch. 6 - Design a class named Pet, which should have the...Ch. 6 - Look at the following partial class definition,...Ch. 6 - Consider the following class declaration: public...Ch. 6 - Look at the following description of a problem...Ch. 6 - The bank offers the following types of accounts to...Ch. 6 - Assume that you are writing an application that...Ch. 6 - What is the difference between a class and an...Ch. 6 - A contractor uses a blueprint to build a set of...Ch. 6 - What is an accessor method? What is a mutator...Ch. 6 - is it a good idea to make fields private? Why or...Ch. 6 - If a class has a private field, what has access to...Ch. 6 - Prob. 6SACh. 6 - Assume a program named MailList.java is stored in...Ch. 6 - Why are constructors useful for performing...Ch. 6 - Under what circumstances does Java automatically...Ch. 6 - What do you call a constructor that accepts no...Ch. 6 - Prob. 11SACh. 6 - How does method overloading improve the usefulness...Ch. 6 - Employee Class Write a class named Employee that...Ch. 6 - Car Class Write a class named Car that has the...Ch. 6 - Personal Information Class Design a class that...Ch. 6 - Retail Item Class Write a class named RetailItem...Ch. 6 - Payroll Class Design a Payroll class that has...Ch. 6 - TestScores Class Design a TestScores class that...Ch. 6 - Circle Class Write a Circle class that has the...Ch. 6 - Temperature Class Write a Temperature class that...Ch. 6 - Days in a Month Write a class named MonthDays, The...Ch. 6 - A Game of Twenty-One For this assignment, you will...Ch. 6 - Freezing and Boiling Points The following table...Ch. 6 - SavingsAccount Class Design a SavingsAccount class...Ch. 6 - Deposit and Withdrawal Files Use Notepad or...Ch. 6 - Patient Charges Write a class named Patient that...Ch. 6 - Dice Game Write a program that uses the Die class...Ch. 6 - Roulette Wheel Colors On a roulette wheel, the...Ch. 6 - Coin Toss Simulator Write a class named Coin. The...Ch. 6 - Tossing Coins for a Dollar For this assignment you...Ch. 6 - Fishing Game Simulation For this assignment, you...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
The ____________ is always transparent.
Web Development and Design Foundations with HTML5 (8th Edition)
Write a function named firstLast2 that takes as input a vector of integers. The function should return true if ...
Problem Solving with C++ (9th Edition)
How is a constructor used?
Starting out with Visual C# (4th Edition)
Explain why the rapid delivery and deployment of new systems is often more important to businesses than the det...
Software Engineering (10th Edition)
Theprogramming language is now used to develop large-scale enterprise applications, to enhance the functionalit...
Java How To Program (Early Objects)
Assume mystring references a string. Write a statement that uses a slicing expression and displays the last 3 c...
Starting Out with Python (4th 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
- Write code to declare and create a Random class object (use the rand object reference variable). Then, using the nextInt method, create a list of expressions that produce random numbers in the following ranges, including the end points. Use the nextInt method's iteration that only takes an integer input.a. 0 to 10 b. 0 to 500c. 1 to 10d. 1 to 500e. 25 to 50f. -10 to 15 Write code to declare and create a Random class object (use the rand object reference variable). Then, using the nextInt method, create a list of expressions that produce random numbers in the following ranges, including the end points. Use the nextInt method's iteration that only takes an integer input.a. 0 to 10 b. 0 to 500c. 1 to 10d. 1 to 500e. 25 to 50f. -10 to 15arrow_forwardCreate the following class diagram: The print method in: - Author prints the Authors data - Page prints page no and text - Textbook prints the subject and all pages - Novel prints the genre and all pages The toString method in: - Book returns title and authors - textbook returns subject in additions to super toString - Novel genre in additions to super toString Test your implementation create objects of different types example : - Create a book of type Novel which has many pages and several authors - Create a book of type Textbook which has many pages and several authors - Access these objects polymorphically, variable of class book contains objects of its subclasses Textbook and novel - Print a hall book - Print a single page of a book - Print the book and its authorsarrow_forwardclass Point: """ A point in a two-dimensional coordinate plane """ def __init__(self, x, y): """ Create a point with an x and y coordinate """ self.x = x self.y = y def __str__(self): """ Generate a string representation of a point """ return "(" + str(self.x) + "," + str(self.y) + ")" ############################# Part 1 - Rectangle Class############################class Rectangle: """ A rectangle in a two-dimensional coordinate plane """ def __init__(self, bottom_left_x, bottom_left_y, top_right_x, top_right_y): """ Create a rectangle defined by its bottom left and top right corner coordinates """ self.bottom_left = Point(bottom_left_x, bottom_left_y) self.top_right = Point(top_right_x, top_right_y) def __str__(self): """ Generate a string representation of a rectangle """ return ("Rectangle with…arrow_forward
- Read the instructions below and write your code using Microsoft Visual Studio (Community version). Build your own console application with C#. Write a Rectangle class, the private data members are the length (len) and width (wid) of the rectangle, the parameterless constructor sets len and wid to 0, and the parameterized constructor sets the value of length (len) and width (wid). In addition, the class also includes common methods such as calculating the perimeter of the rectangle, calculating the area of the rectangle, obtaining the length value of the rectangle, obtaining the width value of the rectangle, and modifying the length and width values of the rectangle to the corresponding formal parameter values. Please upload your executable C# file as attachment in the system.arrow_forwardclass Point: """ A point in a two-dimensional coordinate plane """ def __init__(self, x, y): """ Create a point with an x and y coordinate """ self.x = x self.y = y def __str__(self): """ Generate a string representation of a point """ return("(" + str(self.x) + "," + str(self.y) + ")") # Part 1 - Rectangle Classclass Rectangle: """ A rectangle in a two-dimensional coordinate plane """ def __init__(self, bottom_left_x, bottom_left_y, top_right_x, top_right_y): """ Create a rectangle defined by its bottom left and top right corner coordinates """ self.bottom_left = Point(bottom_left_x, bottom_left_y) self.top_right = Point(top_right_x, top_right_y) self.bottom_right = Point(top_right_x, bottom_left_y) self.top_left = Point(bottom_left_x, top_right_y) def __str__(self): """ Generate a string…arrow_forwardMUST BE IN JAVA In an n-sided regular polygon, all sides have the same length and all angles have the same degree (i.e., the polygon is both equilateral and equiangular). Design a class named RegularPolygon that contains: - A private int data field named n that defines the number of sides in the polygon with default value 3. - A private double data field named side that stores the length of the side with default value 1. - A private double data field named x that defines the x-coordinate of the polygon’s center with default value 0. - A private double data field named y that defines the y-coordinate of the polygon’s center with default value 0. - A no-arg constructor that creates a regular polygon with default values. - A constructor that creates a regular polygon with the specified number of sides and length of side, centered at (0, 0). - A constructor that creates a regular polygon with the specified number of sides, length of side, and x- and y-coordinates. - The accessor and…arrow_forward
- Answer true or false and correct the answer for the following questions.- The Caption tool is used to enter title to the object.arrow_forwardOOP1 - Objects, Classes, and Encapsulation Create a program that has the following method and corresponding usage. 1. AreaCircle - compute the area of the circlearrow_forwardPlease use java. The invoice-printing program is somewhat unrealistic because the formatting of theLineItem objects won’t lead to good visual results when the prices and quantities havevarying numbers of digits. Enhance the format method in two ways: Accept an int[]array of column widths as an argument. Use the NumberFormat class to format the currency valuesarrow_forward
- #Write your class code here using python print("Box 1")b1 = box([10,10,10])print("=========================")print("Height:", b1.height)print("Width:", b1.width)print("Breadth:", b1.breadth)print("-------------------------")print("Box 2")b2 = box((30,10,10))print("=========================")print("Height:", b2.height)print("Width:", b2.width)print("Breadth:", b2.breadth)b2.height = 300print("Updating Box 2!")print("Height:", b2.height)print("Width:", b2.width)print("Breadth:", b2.breadth)print("-------------------------")print("Box 3")b3 = b2print("Height:", b3.height)print("Width:", b3.width)print("Breadth:", b3.breadth)arrow_forwardA subject that can modify or write to an object but not having the authority to read it is known as what? Read-Only Append Execute Read-Writearrow_forwardThe code below demonstrates the Idea of constructor overloading. However, the programmer forgot to add the main function to execute the code. Produce the main function and create three object variables, one for each of the constructors and initialize them. By using the display() method, write the necessary codes to display the output of the each constructor. #include <iostream> using namespace std; class CHELSEA { private: int x,y; public: CHELSEA () //constructor 1 with no arguments { x = y = 0; } CHELSEA(int a) //constructor 2 with one argument { x = y = a; } CHELSEA(int a,int b) //constructor 3 with two argument { x = a; 4 y = b; } void display() { cout << "x = " << x << " and " << "y = " << y << endl; } };arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Microsoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
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