Java How To Program (Early Objects)
Java How To Program (Early Objects)
10th Edition
ISBN: 9780133807943
Author: Deitel, Paul
Publisher: Pearson Education
bartleby

Concept explainers

bartleby

Videos

Textbook Question
Book Icon
Chapter 4, Problem 19.1E

(Another Dangling-else Problem) Based on the dangling-else discussion in Exercise 4.27, state the output for each of the following code segments when x is 9 and y is 11 and when x is 11 and y is 9. We eliminated the indentation from the following code to make the problem more challenging. [Hint: Apply the indentation conventions you’ve learned.]

  1. 1 if (x < 10)
  2. 2 if (y > 10)
  3. 3 System.out.println("*****");
  4. 4 else
  5. 5 System.out.println("#####");
  6. 6 System.out.println("$$$$$");
  7. 7 if (x < 10) {
  8. 8 if (y > 10)
  9. 9 System.out.println("*****");
  10. 10 }
  11. 11 else {
  12. 12 System.out.println("#####");
  13. 13 System.out.println("$$$$$");
  14. 14 }
Blurred answer
Students have asked these similar questions
58
Problem 4. (Regular Expressions-using Python re or Java regex) Write a regular expression for the following word patterns: 1. Word starts with a 'q'. Word has 'th'. 2. 3. Word has an 'q' or a 'Q'. 4. Word starts with an 'q' or an 'Q'. 5. Word has both 'o' and 'u' in it. 6. Word does not have an 'a'
( C PROGRAMMING ONLY) 2. Solving a Person's Lonelinessby CodeChum Admin It's been 1,245 years and our sole Person is getting lonelier each day. This Person definitely needs a partner!   Thus, we need to update our Person's design to have a gender as well and there shall be male and female!     Instructions: In the code editor, you are provided with the definition of a struct Person. This struct needs an integer value for its age. Furthermore, you are provided with a displayPerson() function which accepts a struct Person as its parameter.Your task is to first update the struct Person so that it can have a gender as well. For this program, we shall represent a gender with a single character: 'M' for male and 'F' for female.Then, create a Person, take in an integer user input and a character user input, and then set them as the Person's age and gender respectively.Finally, call the displayPerson() function and pass that Person you created.Input 1. The age of the Person 2. The gender of…

Chapter 4 Solutions

Java How To Program (Early Objects)

Ch. 4 - State whether each of the following is true or...Ch. 4 - State whether each of the following is true or...Ch. 4 - State whether each of the following is true or...Ch. 4 - Prob. 2.6SRECh. 4 - State whether each of the following is true or...Ch. 4 - Prob. 2.8SRECh. 4 - State whether each of the following is true or...Ch. 4 - State whether each of the following is true or...Ch. 4 - Write four different Java statements that each add...Ch. 4 - Write Java statements to accomplish each of the...Ch. 4 - Write Java statements to accomplish each of the...Ch. 4 - Write Java statements to accomplish each of the...Ch. 4 - Write Java statements to accomplish each of the...Ch. 4 - Write a Java statement to accomplish each of the...Ch. 4 - Write a Java statement to accomplish each of the...Ch. 4 - Write a Java statement to accomplish each of the...Ch. 4 - Write a Java statement to accomplish each of the...Ch. 4 - Combine the statements that you wrote in Exercise...Ch. 4 - Determine the value of the variables in the...Ch. 4 - Identify and correct the errors in each of the...Ch. 4 - What is wrong with the following while statement?...Ch. 4 - Compare and contrast the if single-selection...Ch. 4 - Explain what happens when a Java program attempts...Ch. 4 - Describe the two ways in which control statements...Ch. 4 - What type of iteration would be appropriate for...Ch. 4 - What is the difference between preincrementing and...Ch. 4 - Prob. 6.1ECh. 4 - What does the following program print? 1. //...Ch. 4 - 1. Read the problem statement. 2. Formulate the...Ch. 4 - 1. Read the problem statement. 2. Formulate the...Ch. 4 - 1. Read the problem statement. 2. Formulate the...Ch. 4 - 1. Read the problem statement. 2. Formulate the...Ch. 4 - (Find the Largest Number) The process of finding...Ch. 4 - Prob. 13.1ECh. 4 - (Find the Two Largest Numbers) Using an approach...Ch. 4 - Prob. 15.1ECh. 4 - What does the following program print? 1. //...Ch. 4 - What does the following program print? 1. //...Ch. 4 - (Dangling-else Problem) The Java compiler always...Ch. 4 - (Another Dangling-else Problem) Based on the...Ch. 4 - (Another Dangling-else Problem) Based on the...Ch. 4 - Prob. 21.1ECh. 4 - (Palindromes) A palindrome is a sequence of...Ch. 4 - (Printing the Decimal Equivalent of a Binary...Ch. 4 - (Checkerboard Pattern of Asterisks) Write an...Ch. 4 - (Multiples of 2 with an Infinite Loop) Write an...Ch. 4 - (Whats Wrong with This Code?) What is wrong with...Ch. 4 - Prob. 27.1ECh. 4 - Prob. 28.1ECh. 4 - Write an application that estimates the value of...Ch. 4 - Write an application that computes the value of e...Ch. 4 - (Enforcing Privacy with Cryptography) The...Ch. 4 - (World Population Growth) World population has...
Knowledge Booster
Background pattern image
Computer Science
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
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
Literals in Java Programming; Author: Sudhakar Atchala;https://www.youtube.com/watch?v=PuEU4S4B7JQ;License: Standard YouTube License, CC-BY
Type of literals in Python | Python Tutorial -6; Author: Lovejot Bhardwaj;https://www.youtube.com/watch?v=bwer3E9hj8Q;License: Standard Youtube License