Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
11th Edition
ISBN: 9780134670942
Author: Y. Daniel Liang
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 15.9, Problem 15.9.4CP
If the following code is inserted in line 57 in Listing 15.9, what is the output if the user presses the key for letter A? What is the output if the user presses the up arrow key?
circlePane.setOnKeyPressed(e →
System.out.println(“Key pressed ” + e.getCode()));
circlePane.setOnKeyTyped(e →
System.out.println(“Key typed ” + e.getCode()));
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
4. A) What will be the value of x after the following code is executed?
int x, y = 4, z = 6;
x = (y++) * (++z);
B) Suppose a = 1. What is the value of a after the following code executes? Show the procedure to reach your answer
if(a > 0)
{
switch(a)
{
case 1:
a = a + 3;
case 3:
a++;
case 6:
a = a * 2;
break;
case 8:
a--;
break;
default
a++;
}
else
a = a + 2;
C) What would be the value of x after the following statements were executed?
int x = 10;
switch (x)
{
case 10:
x += 15;
case 12:
x -= 5;
break;
default:
x *= 3;
}
What output is produced by the following code? For each output line, describewhether the line begins or ends with a blank or blanks.String aString = "Jelly beans";double d = 123.1234567890;System.out.println("START1234567890");System.out.printf("START%sEND %n %9.4f %n", aString, d);
What is the printout of the following code?
x = 1
def f1():
x=3
print(x)
f1()
print(x)
Chapter 15 Solutions
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
Ch. 15.2 - Prob. 15.2.1CPCh. 15.2 - Prob. 15.2.2CPCh. 15.3 - Why must a handler be an instance of an...Ch. 15.3 - Explain how to register a handler object and how...Ch. 15.3 - Prob. 15.3.3CPCh. 15.3 - What is the registration method for a button to...Ch. 15.4 - Can an inner class be used in a class other than...Ch. 15.4 - Can the modifiers public, protected, private, and...Ch. 15.5 - Prob. 15.5.1CPCh. 15.5 - What is wrong in the following code?
Ch. 15.6 - Prob. 15.6.1CPCh. 15.6 - What is a functional interface? Why is a...Ch. 15.6 - Prob. 15.6.3CPCh. 15.8 - Prob. 15.8.1CPCh. 15.8 - Prob. 15.8.2CPCh. 15.9 - Prob. 15.9.1CPCh. 15.9 - Prob. 15.9.2CPCh. 15.9 - Prob. 15.9.3CPCh. 15.9 - If the following code is inserted in line 57 in...Ch. 15.10 - Prob. 15.10.1CPCh. 15.11 - Prob. 15.11.1CPCh. 15.11 - Prob. 15.11.2CPCh. 15.11 - Prob. 15.11.3CPCh. 15.11 - Prob. 15.11.4CPCh. 15.12 - How does the program make the ball appear to be...Ch. 15.12 - How does the code in Listing 15.17, BallPane.java,...Ch. 15.12 - What does the program do when the mouse is pressed...Ch. 15.12 - If line 32 in Listing 15.18, BounceBall.java, is...Ch. 15.12 - Prob. 15.12.5CPCh. 15.13 - Prob. 15.13.1CPCh. 15.13 - What would happen if map is replaced by scene in...Ch. 15.13 - Prob. 15.13.3CPCh. 15 - Prob. 15.1PECh. 15 - (Rotate a rectangle) Write a program that rotates...Ch. 15 - (Move the ball) Write a program that moves the...Ch. 15 - (Create a simple calculator) Write a program to...Ch. 15 - (Create an investment-value calculator) Write a...Ch. 15 - (Alternate two messages) Write a program to...Ch. 15 - (Change color using a mouse) Write a program that...Ch. 15 - (Display the mouse position) Write two programs,...Ch. 15 - (Draw lines using the arrow keys) Write a program...Ch. 15 - (Enter and display a string) Write a program that...Ch. 15 - (Move a circle using keys) Write a program that...Ch. 15 - Prob. 15.12PECh. 15 - (Geometry: inside a rectangle?) Write a program...Ch. 15 - Prob. 15.14PECh. 15 - Prob. 15.15PECh. 15 - (Two movable vertices and their distances) Write a...Ch. 15 - (Geometry: find the bounding rectangle) Write a...Ch. 15 - Prob. 15.18PECh. 15 - (Game: eyehand coordination) Write a program that...Ch. 15 - Prob. 15.20PECh. 15 - (Drag points) Draw a circle with three random...Ch. 15 - (Auto resize cylinder) Rewrite Programming...Ch. 15 - Prob. 15.23PECh. 15 - Prob. 15.24PECh. 15 - Prob. 15.25PECh. 15 - Prob. 15.26PECh. 15 - Prob. 15.27PECh. 15 - (Display a running fan) Write a program that...Ch. 15 - (Racing car) Write a program that simulates car...Ch. 15 - Prob. 15.30PECh. 15 - Prob. 15.31PECh. 15 - (Control a clock) Modify Listing 14.21,...Ch. 15 - (Game: bean-machine animation) Write a program...Ch. 15 - Prob. 15.34PECh. 15 - Prob. 15.35PECh. 15 - Prob. 15.36PE
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
Summarize the mathematical order of operations, as it works in most programming languages.
Starting Out with Programming Logic and Design (4th Edition)
Explain how each of the following types of integrity constraints is enforced in the SQL CREATE TABLE commands: ...
Modern Database Management
Write a fragment of code that will change the integer value stored in x as follows. If x is even, divide x by 2...
Java: An Introduction to Problem Solving and Programming (8th Edition)
What is the output produced by the following (when embedded in a correct program with x declared to be of type ...
Problem Solving with C++ (10th Edition)
Assuming that intNumber is an integer variable, what value will each of the following statements assign to it? ...
Starting Out With Visual Basic (8th Edition)
T F: The multiplication operator has higher precedence than the addition operator.
Starting Out With Visual Basic (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
- The last line of the code, is there something missing on it? The last line says, "move $v0, "arrow_forwardWhat is the output from the following code: IdentifyMyParts a = new IdentifyMyParts(); IdentifyMyParts b = new IdentifyMyParts(); a.y = 5; b.y = 6; a.x = 1; b.x = 2; System.out.println("a.y = " + a.y); System.out.println("b.y = " + b.y); System.out.println("a.x = " + a.x); System.out.println("b.x = " + b.x); System.out.println("IdentifyMyParts.x = " + IdentifyMyParts.x);arrow_forwardError on line 181, in generating the slip, is my info in .txt is wrong? Code: class EmployeeInfo:emp_number = 0emp_last = ""emp_first = ""emp_position = ""emp_department = ""emp_birth = ""emp_RD = 0emp_NDWM = 0def setEmpNumber(self,emp_number):self.emp_number = emp_numberdef setEmpLast(self,emp_last):self.emp_last = emp_lastdef setEmpFirst(self,emp_first):self.emp_first = emp_firstdef setEmpPositio(self,emp_position):self.emp_position = emp_positiondef setEmpDepartment(self,emp_department):self.emp_department = emp_departmentdef setEmpBirth(self,emp_birth):self.emp_birth = emp_birthdef setRD(self,emp_RD):self.emp_RD = emp_RDdef setNDWM(self,emp_NDWM):self.emp_NDWM = emp_NDWMdef add_emp(self):with open('employee.txt', 'a+') as f:self.emp_number = int(input("Enter emp number: "))self.emp_last = input("Enter emp last: ")self.emp_first = input("Enter emp first: ")self.emp_position = input("Enter emp position: ")self.emp_department = input("Enter emp department: ")if self.emp_position ==…arrow_forward
- In the following code stream, identify if there are any hazards. Crisply describe if it is possible to get around the hazards, and what the resulting steps will be. lw r2, 0(r1) add r3, r2, r3 sub r1, r1, r4arrow_forwardPlease do base coverage for code given below with two characteristics public void tick() throws SnakeHitYardWallException { long current = this.clockProvider.getTime(); long dif = current - this.time; this.time = current; if (dif >= delay) { this.yard.getSnake().move(); } }arrow_forwardWhich input value causes the loop body to execute a 2nd time, thus outputting "In loop" again? Strings="Go";while ((!s.equals("q")) && (!s.equals("Q"))) {System.out.println("In loop");s = scnr.next();} a. "q" only b. "Q" only c. Either "q" or "Q" d. "Quit" JAVAarrow_forward
- Given string userString on one line, character charToFind on a second line, and integer strIndex on a third line, output "Found match" if the character at index strIndex of userString matches charToFind. Otherwise, output "No match". End with a newline. Ex: If the input is: warmth a 1 then the output is: Found match import java.util.Scanner; public class MatchingChar { public static void main(String[] args) { Scanner scnr = new Scanner(System.in); String userString; char charToFind; int strIndex; userString = scnr.nextLine(); charToFind = scnr.next().charAt(0); strIndex = scnr.nextInt(); /* Your code goes here */ } }arrow_forwardAfter the execution of the following lines of code which variables are aliases? int[] a = { 1, 2, 3 };int[] b = { 1, 1, 1 };int[] y = { 1, 2, 3 };a = b;b = new int[1];y = b; .there are no aliases here .a and b are aliases .a, b, and y are aliases .y and b are aliasesarrow_forwardMany user-created passwords are simple and easy to guess. Write a program that takes a simple password and makes it stronger by replacing characters using the key below, and by appending "q*s" to the end of the input string. i becomes ! a becomes @ m becomes M B becomes 8 o becomes . Ex: If the input is: Mypassword The output is: Myp@ssw.rdq*s Write a program to get the above task done. Use switch statement to handle the conditional part of the code.arrow_forward
- The do-while in my code does not work. when I enter yes, I can't input the name of the customer, what could be wrong with the code? Also, when entering the wrong item code, I want it to display invalid output and the system will ask to perform another transaction. package cashier; import java.util.Scanner; class List { Scanner sc = new Scanner(System.in);private String name;private int item;private int[] des;private double price;private int[] quan;private double total;private double[] sum; public List(String name, int item, int[] des, double total, int[] quan, double[] sum) {this.name = name;this.item = item;this.des = des;this.quan = quan;this.total = total;this.sum = sum;}public void Input() {System.out.print("\n Enter name of customer: ");name = sc.nextLine();System.out.print(" Enter number of items: ");item = sc.nextInt();des = new int[item];quan = new int[item];sum = new double[item];total = 0; for (int i = 0; i < item; i++) {System.out.print("\n Enter item code: ");des[i] =…arrow_forwardWhat is the output of the following code fragment? int a = 10, b = 3; boolean answer = ((--a >= 10) && (--b == 20)); System.out.println(a + "," + b + "," + answer);arrow_forwardI have this code ( C#): there is an error, as in attached, What is the problem? >>>>>>>>>>>>>>>>>>>>>>>>>>>> using System;public class Rectangle{ double width, length, coorx, coory; public Rectangle() { width = 1; length = 1; coorx = 0; coory = 0; } public void move(double x, double y) { coorx += x; coory += y; } public double getArea() { return width * length; } public double getPerimeter() { return 2 * (width + length); } public override string ToString() { return "Rectangle with width: " + width.ToString() + ", length: " + length.ToString() + " with its center at : (" + coorx.ToString() + ", " + coory.ToString() + ")\n"; } public static void Main() { Rectangle[] arr = new Rectangle[2]; arr[0] = new Rectangle(); arr[1] = new Rectangle(3,4,0,0);…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,
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Java random numbers; Author: Bro code;https://www.youtube.com/watch?v=VMZLPl16P5c;License: Standard YouTube License, CC-BY