Objects First with Java: A Practical Introduction Using BlueJ (6th Edition)
6th Edition
ISBN: 9780134477367
Author: David J. Barnes, Michael Kolling
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Textbook Question
Chapter 2, Problem 36E
Write down exactly what will be printed by the following statement:
System. out. Println ("My cat has green eyes.");
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Please create a code that follows the directions below exactly, and have the output look just like the one in the picture provided. If possible, please refrain from using switch statements in the code.
Insturctions:
This assignment will assess your understanding of void and value returning static methods.
Your cousin owns an automotive maintenance shop that performs routine maintenance on cars. He has asked you to write a program that will provide a list of services (and their respective prices) to users and allow them to choose any, or all, services they would like and display the final price, including a 28% labor charge, a 9% markup if the car is an import, and an 8% sales tax.
Task
To accomplish the above, do the following:
Write the two methods outlined below.
Test your program and screenshot your successful test.
carMaintenance method
This method should accept the make of the car as a parameter (e.g., BMW, Ford, Ferrari, etc.). It should display the services and their prices as…
2. How do you use "else if" and "else"?
3. Replace the (????) with relevant code to run the program. Details about the program have been given below. (Java has been used)
This program should display:
Before:
27 19 34 5 12
After:
0 19 34 5 12
After:
0 0 34 5 12
*/
package finalexamtakehome6;
public class Finalexamtakehome6 {
//
public void print ( int[] x )
{
while ( int j=0; j < x.length; j++ )
System.out.print( x[0] + " " );
System.out.println( );
}
public void changeElement ( int[] x, int elt )
{
if ( elt x.length )
x[ elt ] = 0;
}
//
public static void main(String[] args) {
Finalexamtakehome6 cng = new Finalexamtakehome6();
int[] value = {27, 19, 34, 5, 12} ;
int chgelt = 0;
System.out.println( "Before:" );
cng.print( value );
cng.changeElement( value, chgelt );
System.out.println( "After:" );
cng.print( value );
chgelt =…
Chapter 2 Solutions
Objects First with Java: A Practical Introduction Using BlueJ (6th Edition)
Ch. 2 - Create a TicketMachine object on the object bench...Ch. 2 - What value is returned if you get the machine's...Ch. 2 - Prob. 3ECh. 2 - Prob. 4ECh. 2 - Create another ticket machine for tickets of a...Ch. 2 - Prob. 6ECh. 2 - Does it matter whether we write...Ch. 2 - Prob. 8ECh. 2 - Put back the word public, and then check whether...Ch. 2 - From your earlier experimentation with the ticket...
Ch. 2 - Prob. 11ECh. 2 - Prob. 12ECh. 2 - Prob. 13ECh. 2 - Prob. 14ECh. 2 - In the following field declaration from the...Ch. 2 - Prob. 16ECh. 2 - Prob. 17ECh. 2 - To what class does the following constructor...Ch. 2 - How many parameters does the following constructor...Ch. 2 - Prob. 20ECh. 2 - Suppose that the class Pet has a field called name...Ch. 2 - Challenge exercise The following object creation...Ch. 2 - Compare the header and body of the getBalance...Ch. 2 - If a call to getPrice can be characterized as...Ch. 2 - If the name of getBalance is changed to getAmount,...Ch. 2 - Prob. 26ECh. 2 - Try removing the return statement from the body of...Ch. 2 - Compare the method headers of getPrice and...Ch. 2 - Do the insertMoney and printTicket methods have...Ch. 2 - Create a ticket machine with a ticket price of...Ch. 2 - How can we tell from just its header that setPrice...Ch. 2 - Complete the body of the setPrice method so that...Ch. 2 - Prob. 33ECh. 2 - Is the increase method a mutator? If so, how could...Ch. 2 - Prob. 35ECh. 2 - Write down exactly what will be printed by the...Ch. 2 - Add a method called prompt to the TicketMachine...Ch. 2 - Prob. 38ECh. 2 - What about the following version?
Ch. 2 - Prob. 40ECh. 2 - Add a showPrice method to the TicketMachine class....Ch. 2 - Create two ticket machines with differently priced...Ch. 2 - Modify the constructor of TicketMachine so that it...Ch. 2 - Give the class two constructors. One should take a...Ch. 2 - Implement a method, empty, that simulates the...Ch. 2 - Prob. 46ECh. 2 - Predict what you think will happen if you change...Ch. 2 - Rewrite the if-else statement so that the method...Ch. 2 - Prob. 49ECh. 2 - In this version of printTicket, we also do...Ch. 2 - Is it possible to remove the else part of the...Ch. 2 - After a ticket has been printed, could the value...Ch. 2 - So far, we have introduced you to two arithmetic...Ch. 2 - Write an assignment statement that will store the...Ch. 2 - Write an assignment statement that will divide the...Ch. 2 - Prob. 56ECh. 2 - Modify your answer to the previous exercise so...Ch. 2 - Why does the following version of refundBalance...Ch. 2 - What happens if you try to compile the...Ch. 2 - What is wrong with the following version of the...Ch. 2 - Add a new method, emptyMachine, that is designed...Ch. 2 - Rewrite the printTicket method so that it declares...Ch. 2 - Challenge exercise Suppose we wished a single...Ch. 2 - List the name and return type of this method:
Ch. 2 - Prob. 65ECh. 2 - Write out the outer wrapping of a class called...Ch. 2 - Write out definitions for the following fields:
Ch. 2 - Write out a constructor for a class called Module....Ch. 2 - Prob. 69ECh. 2 - Correct the error in this method:...Ch. 2 - Write an accessor method called getName that...Ch. 2 - Write a mutator method called setAge that takes a...Ch. 2 - Write a method called printDetails for a class...Ch. 2 - Draw a picture of the form shown in Figure 2.3,...Ch. 2 - Prob. 75ECh. 2 - Create a Student with name "djb" and id "859012"....Ch. 2 - Prob. 77ECh. 2 - Challenge exercise Modify the getLoginName method...Ch. 2 - Consider the following expressions. Try to predict...Ch. 2 - Open the Code Pad in the better-ticket-machine...Ch. 2 - Now add the following in the Code Pad:...Ch. 2 - Add the following: t1.InsertMoney500; What would...Ch. 2 - Prob. 83ECh. 2 - Prob. 84ECh. 2 - Add a field, pages, to the Book class to store the...Ch. 2 - Are the Book objects you have implemented...Ch. 2 - Add a method, printDetails, to the Book class....Ch. 2 - Add a further field, refNumber, to the Book class....Ch. 2 - Modify your printDetai 1 s method to include...Ch. 2 - Prob. 90ECh. 2 - Add a further integer field, borrowed, to the Book...Ch. 2 - Prob. 92ECh. 2 - Prob. 93ECh. 2 - Prob. 94E
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
State the order of evaluation of the operators in each of the following C statements and show the value of x af...
C How to Program (8th Edition)
If a class has a private field, what has access to the field?
Starting Out with Java: From Control Structures through Objects (6th Edition)
________ is the process of inspecting input values and determining whether they are valid.
Starting Out With Visual Basic (7th Edition)
Explain how entities are transformed into tables.
Database Concepts (8th Edition)
Write a grading program for a class with the following grading policies: a. There are two quizzes, each graded ...
Problem Solving with C++ (9th Edition)
Modify the temperature conversion program to print a heading above the table.
C Programming Language
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
- You are responsible for adding the appropriate testing code to your main. a. The getValedictorian method returns the valedictorian of the class, that is the student with the highest grade point average. Implement this new method. b. The getHonorsPercent method returns the percentage of students in the class who are in the honors program. Use 3.75 as the cutoff GPA. Implement this method. Also print the list of students, by using the isHonor method, in the Honors program. c. An alternate implementation for the School class is being considered, in which the students are stored in an ArrayList instead of an array. Show how the declaration of the data field students would look in this alternate design. MAIN CLASS: import java.util.ArrayList; public class Main { public static void main(String[] args) { System.out.println("Unit07Project2 by Your Name"); System.out.println(); int size = 10; School onw = new School(size); /* Add the code…arrow_forwardPlease be aware that your score will be zero if your codes are the same as others'. Do not cheat. ! 空題 1. The JDK command to compile a class in the file Test.java is 2. The main method header is written as 3. Suppose a Scanner object is created as follows: Scanner input = new Scanner(System.in); What method do you use to read a double type number? What is y after the following statement is executed? x = -1; y = (x < 0) ? 10: -10; What is the index variable for the element at the first row and first column in array a? 4. 5.arrow_forwardFollow the usual approach: read the documentation carefully, read the first test class, write the method being tested.: JAVA public EmployeeUtilities() \\constructor\\ Constructor does nothing, i.e. public EmployeeUtilities() {} ------------------ getEmployeeWithMostHours public Employee getEmployeeWithMostHours(Employee[] emps) Returns the Employee object with the most hours worked in a week over all the Employees in an input array. You can assume the array is full, i.e. there are no null elements. Parameters: emps - An array of Employee objects Returns: The Employee object with the most hours worked in a week over all the Employees in an input array. ------------------------ getHoursArray public double[] getHoursArray(Employee[] emps) Returns an array of just the total hours for each Employee in the input array. For example, if the input array has three employees with total hours: 40, 50, 20, then a double array will be returned with these values: [40,50,20] Parameters: emps - An…arrow_forward
- For the 8 Java statements below, identify each of the following statements as legal or illegal, and whether legal or not, state whether it represents a "narrowing" or "widening" conversion, or neither. Don't forget to identify the last statement at the very bottom, Member m = new BoardMember();, as legal or illegal and widening or narrowing conversion.arrow_forwardhttps://youtu.be/4hAoK54Pfdc Here is a video regarding the kit component.arrow_forwardHey can you make a verify class for a credit card. My variable are first name, last name, creditnum, month, year, and last 3 digits. I need to verify that each one only uses letter or numbers.arrow_forward
- Take a look at the header of the method below, and then implement a sample call to it in your code.empty public ShowValue ()arrow_forwardplease answer with proper explanation. i will give u upvote. (JAVA) This is what I have so far. Not sure where to go from here. Thanks for your help!arrow_forwardLook at the header of the method below, and then implement a sample call to it in your code.private static void ShowValue ()arrow_forward
- Correct the following wrong statements. In Java, once a variable is declared in a method as local variable, it will be visible and could be used in any other method in the program.arrow_forwardConsider that there are two variables already declared with values a=10 and b-11. Which of the following code snippets will result in exchanging the value of the variables a and b?arrow_forwardPlease help with the rest of the subparts of the code! The first three were very good!arrow_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
Java Math Library; Author: Alex Lee;https://www.youtube.com/watch?v=ufegX5o8uc4;License: Standard YouTube License, CC-BY