Java: An Introduction to Problem Solving and Programming (7th Edition)
7th Edition
ISBN: 9780133766264
Author: Walter Savitch
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 8.2, Problem 16STQ
Consider the code below, which was discussed in the previous section:
Student joe = new Student(“Joe Student”, 2001);
System.out.printin(joe.tostring());
Why is the output on two lines instead of being all on one line?
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Instructor note:
This lab is part of the assignment for this chapter.
This lab uses two Java files, LabProgram.java and SimpleCar.java. The SimpleCar class has been developed and provided to you already. You don't need to change anything in that class. Your job is to use the SimpleCar class to complete the specified tasks in the main() method of LabProgram.java
Given two integers that represent the miles to drive forward and the miles to drive in reverse as user inputs, create a SimpleCar object that performs the following operations:
Drives input number of miles forward
Drives input number of miles in reverse
Honks the horn
Reports car status
The SimpleCar class is found in the file SimpleCar.java.
Ex: If the input is:
100 4
the output is:
beep beep Car has driven: 96 miles
Iterating over a collection of items is the job of the for construct's looping
mechanism. So long as there are things to process, it will keep running forever.
So, what do you make of this?
https://youtu.be/4hAoK54Pfdc Here is a video regarding the kit component.
Chapter 8 Solutions
Java: An Introduction to Problem Solving and Programming (7th Edition)
Ch. 8.1 - Prob. 1STQCh. 8.1 - Suppose the class SportsCar is a derived class of...Ch. 8.1 - Suppose the class SportsCar is a derived class of...Ch. 8.1 - Can a derived class directly access by name a...Ch. 8.1 - Can a derived class directly invoke a private...Ch. 8.1 - Prob. 6STQCh. 8.1 - Suppose s is an object of the class Student. Base...Ch. 8.2 - Give a complete definition of a class called...Ch. 8.2 - Add a constructor to the class Student that sets...Ch. 8.2 - Rewrite the definition of the method writeoutput...
Ch. 8.2 - Rewrite the definition of the method reset for the...Ch. 8.2 - Can an object be referenced by variables of...Ch. 8.2 - What is the type or types of the variable(s) that...Ch. 8.2 - Prob. 14STQCh. 8.2 - Prob. 15STQCh. 8.2 - Consider the code below, which was discussed in...Ch. 8.2 - Prob. 17STQCh. 8.3 - Prob. 18STQCh. 8.3 - Prob. 19STQCh. 8.3 - Is overloading a method name an example of...Ch. 8.3 - In the following code, will the two invocations of...Ch. 8.3 - In the following code, which definition of...Ch. 8.4 - Prob. 23STQCh. 8.4 - Prob. 24STQCh. 8.4 - Prob. 25STQCh. 8.4 - Prob. 26STQCh. 8.4 - Prob. 27STQCh. 8.4 - Prob. 28STQCh. 8.4 - Are the two definitions of the constructors given...Ch. 8.4 - The private method skipSpaces appears in the...Ch. 8.4 - Describe the implementation of the method drawHere...Ch. 8.4 - Is the following valid if ShapeBaSe is defined as...Ch. 8.4 - Prob. 33STQCh. 8.5 - Prob. 34STQCh. 8.5 - What is the difference between what you can do in...Ch. 8.5 - Prob. 36STQCh. 8 - Consider a program that will keep track of the...Ch. 8 - Implement your base class for the hierarchy from...Ch. 8 - Draw a hierarchy for the components you might find...Ch. 8 - Suppose we want to implement a drawing program...Ch. 8 - Create a class Square derived from DrawableShape,...Ch. 8 - Create a class SchoolKid that is the base class...Ch. 8 - Derive a class ExaggeratingKid from SchoolKid, as...Ch. 8 - Create an abstract class PayCalculator that has an...Ch. 8 - Derive a class RegularPay from PayCalculator, as...Ch. 8 - Create an abstract class DiscountPolicy. It should...Ch. 8 - Derive a class BulkDiscount from DiscountPolicy,...Ch. 8 - Derive a class BuyNItemsGetOneFree from...Ch. 8 - Prob. 13ECh. 8 - Prob. 14ECh. 8 - Create an interface MessageEncoder that has a...Ch. 8 - Create a class SubstitutionCipher that implements...Ch. 8 - Create a class ShuffleCipher that implements the...Ch. 8 - Define a class named Employee whose objects are...Ch. 8 - Define a class named Doctor whose objects are...Ch. 8 - Create a base class called Vehicle that has the...Ch. 8 - Create a new class called Dog that is derived from...Ch. 8 - Define a class called Diamond that is derived from...Ch. 8 - Prob. 2PPCh. 8 - Prob. 3PPCh. 8 - Prob. 4PPCh. 8 - Create an interface MessageDecoder that has a...Ch. 8 - For this Programming Project, start with...Ch. 8 - Modify the Student class in Listing 8.2 so that it...Ch. 8 - Prob. 8PPCh. 8 - Prob. 9PPCh. 8 - Prob. 10PP
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
What output will be produced by the following code?
Absolute Java (6th Edition)
7.15 private class member function can be called by A) any other function B) only public functions in the same ...
Starting Out with C++: Early Objects
Using examples, illustrate the different types of adaptor needed to support sequential composition, hierarchica...
Software Engineering (10th Edition)
List the five major hardware components of a computer system.
Starting Out with Java: From Control Structures through Data Structures (3rd Edition)
(Count consonants and vowels) Write a program that prompts the user to enter a text file name and displays the ...
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
Use the following tables for your answers to questions 3.7 through 3.51 : PET_OWNER (OwnerID, OwnerLasst Name, ...
Database Concepts (7th 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
- Use Java.arrow_forwardWant explanation of code alsoarrow_forwardImplement the design of the Pizza class so that the following output is produced:# Write your codes here.# Do not change the following lines of code.print("Pizza Count:", Pizza.pizza_count)print("=======================")p1 = Pizza("Chicken")p1.set_toppings_info(25, 1, 4, 0)p1.display()print("------------------------------------")p2 = Pizza("Olives")p2.set_toppings_info(15, 1.5, 0, 0)p2.display()print("------------------------------------")p3 = Pizza("Sausage")p3.set_toppings_info(50, 5, 2, 0)p3.display()print("=======================")print("Pizza Count:", Pizza.pizza_count)Output:Pizza Count: 0=======================Toppings: Chicken25 calories1 g fat4 g protein0 g carbs------------------------------------Toppings: Olives15 calories1.5 g fat0 g protein0 g carbs------------------------------------Toppings: Sausage50 calories5 g fat2 g protein0 g carbs=======================Pizza Count: 3arrow_forward
- write this code on java.Please give comments for every linearrow_forwardHelp, I making a elevator simulator, I need help in writing code in the Elevator class and it's polymorphism class. I am not sure what to do next. Any help is appreciated. There are 4 types of passengers in the system:Standard: This is the most common type of passenger and has a request percentage of 70%. Standard passengers have no special requirements.VIP: This type of passenger has a request percentage of 10%. VIP passengers are given priority and are more likely to be picked up by express elevators.Freight: This type of passenger has a request percentage of 15%. Freight passengers have large items that need to be transported and are more likely to be picked up by freight elevators.Glass: This type of passenger has a request percentage of 5%. Glass passengers have fragile items that need to be transported and are more likely to be picked up by glass elevators. There are 4 types of elevators in the system:StandardElevator: This is the most common type of elevator and has a request…arrow_forwardComplete the convert() method that casts the parameter from a double to an integer and returns the result.Note that the main() method prints out the returned value of the convert() method. Ex: If the double value is 19.9, then the output is: 19 Ex: If the double value is 3.1, then the output is: 3 code: public class LabProgram { public static int convert(double d){ /* Type your code here */ } public static void main(String[] args) { System.out.println(convert(19.9)); System.out.println(convert(3.1)); }}arrow_forward
- I am having trouble with this: Implement the convertString method based on its specification. Here are some things that can help: the Character class has some utility methods to determine if a character is uppercase, lowercase, or a digit (numeral) the String class has a method to get the character at a specific position (called the index). Find that method and use it. make use of the convert methods you already have!convertString Specification: /** * Converts the letters and numerals in the given string * to their circled counterparts. All other characters * are unchanged. * * @precondition text != null * @postcondition none * * @param text the text to convert * @return a modified version of text, with all letters and numerals * circled. */My code: public class CircleStrings { /** * Converts the letters and numerals in the given string * to their circled counterparts. All other characters * are unchanged. * *…arrow_forwardI am struggling with creating arrays program on eclipse. Struggling with getting the result as asked in assignment. Need help with problem a and b. Please help as soon as you can.arrow_forwardThis is about java programming, please help me with this. I use Netbeans IDE. Please provide a program link for me to understand. Thanksarrow_forward
- Please explain the outputarrow_forwardPlease , give the solution quicklyarrow_forwardUse the following UML diagram to create your java program. Your program should add a test class that outputs the results. Inventory I I + addItem(): void I | + removeItem(): voidl I + updateItem(): voidl + getItem(): Item I Here is a sample output: Name: Sam Smith Age: 25 Street: 123 Main St City: New York State: NY Zip Code: 12345 Item id: int name: String I I I description: String - quantity: int I price: double + getId(): int I 1 + getName(): String I I + getDescription(): String I I I + getQuantity(): int + getPrice(): double Iarrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- 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
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
The Top Down Approach to Software Development; Author: Christopher Kalodikis;https://www.youtube.com/watch?v=v9M8LA2uM48;License: Standard YouTube License, CC-BY