Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
11th Edition
ISBN: 9780134743356
Author: Paul J. Deitel, Harvey Deitel
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Textbook Question
Chapter 2, Problem 14.1E
What does the following code print?
System.out.println("*");
System.out.println("***");
System.out.println("*****");
System.out.println("****");
System.out.println("**");
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
# Python 3
def printFunction(num1, num2): num3 = num1 + num2 return num3print(num3)
Explanation: Here, num3 is the local variable that is defined in the scope of the function and when it is used outside the function, an error occurs. Print(num3) is the statement which is outside the scope of the function. So, when this statement is executed, there is no variable named num3 to be printed, so it gives an error.
The error that occurs is : NameError: name 'num3' is not defined
Construct a function that takes an argument. Give the function parameter a unique name. Show what happens when you try to use that parameter name outside the function. Explain the results.
Show what happens when a variable defined outside a function has the same name as a local variable inside a function. Explain what happens to the value of each variable as the program runs.
Define Declaring and Initializing Variables.
starsPrint ♡
Language/Type:
Java expressions %
What output is produced by each of the following code samples?
// A)
for (int i = 0; i < 5; i++) {
}
for (int j = 0; j < 10; j++) {
System.out.print("*");
}
System.out.println(); // to end the line
// B)
for (int i = 1; i <= 5; i++) {
for (int j = 1; j <= i; j++) {
System.out.print("*");
}
System.out.println();
}
// C)
for (int i = 1; i <= 5; i++) {
for (int j = 1; j <= i; j++) {
System.out.print(i);
}
System.out.println();
M
31
A)
B)
C)
111
C
Submit ¤
U
Chapter 2 Solutions
Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
Ch. 2 - Fill in the blanks in each of the following...Ch. 2 - Fill in the blanks in each of the following...Ch. 2 - Fill in the blanks in each of the following...Ch. 2 - Fill in the blanks in each of the following...Ch. 2 - Fill in the blanks in each of the following...Ch. 2 - Fill in the blanks in each of the following...Ch. 2 - Prob. 1.7SRECh. 2 - State whether each of the following is true or...Ch. 2 - State whether each of the following is true or...Ch. 2 - State whether each of the following is true or...
Ch. 2 - State whether each of the following is true or...Ch. 2 - State whether each of the following is true or...Ch. 2 - Prob. 2.6SRECh. 2 - Write statements to accomplish each of the...Ch. 2 - Write statements to accomplish each of the...Ch. 2 - Write statements to accomplish each of the...Ch. 2 - Prob. 3.4SRECh. 2 - Prob. 3.5SRECh. 2 - Write statements to accomplish each of the...Ch. 2 - Prob. 4.1SRECh. 2 - Identify and correct the errors in each of the...Ch. 2 - Write declarations, statements or comments that...Ch. 2 - Write declarations, statements or comments that...Ch. 2 - Write declarations, statements or comments that...Ch. 2 - Write declarations, statements or comments that...Ch. 2 - Write declarations, statements or comments that...Ch. 2 - Write declarations, statements or comments that...Ch. 2 - Write declarations, statements or comments that...Ch. 2 - Write declarations, statements or comments that...Ch. 2 - Write declarations, statements or comments that...Ch. 2 - Write declarations, statements or comments that...Ch. 2 - Using the statements you wrote in Exercise 2.5,...Ch. 2 - Fill in the blanks in each of the following...Ch. 2 - Fill in the blanks in each of the following...Ch. 2 - Fill in the blanks in each of the following...Ch. 2 - Prob. 1.4ECh. 2 - Fill in the blanks in each of the following...Ch. 2 - Write Java statements that accomplish each of the...Ch. 2 - Write Java statements that accomplish each of the...Ch. 2 - Write Java statements that accomplish each of the...Ch. 2 - Prob. 3.1ECh. 2 - State whether each of the following is true or...Ch. 2 - State whether each of the following is true or...Ch. 2 - State whether each of the following is true or...Ch. 2 - Assuming that x = 2 and y = 3, what does each of...Ch. 2 - Assuming that x = 2 and y = 3, what does each of...Ch. 2 - Assuming that x = 2 and y = 3, what does each of...Ch. 2 - Prob. 4.4ECh. 2 - Prob. 5.1ECh. 2 - Which of the following Java statements contain...Ch. 2 - Prob. 5.3ECh. 2 - Which of the following Java statements contain...Ch. 2 - Given that y=ax3+7, which of the following are...Ch. 2 - Given that y=ax3+7, which of the following are...Ch. 2 - Given that y=ax3+7, which of the following are...Ch. 2 - Given that y=ax3+7, which of the following are...Ch. 2 - Given that y=ax3+7, which of the following are...Ch. 2 - Given that y=ax3+7, which of the following are...Ch. 2 - State the order of evaluation of the operators in...Ch. 2 - Prob. 7.2ECh. 2 - State the order of evaluation of the operators in...Ch. 2 - Display the message "Enter an integer: ", leaving...Ch. 2 - Assign the product of variables b and c to the int...Ch. 2 - Use a comment to state that a program performs a...Ch. 2 - Prob. 9.1ECh. 2 - (Comparing Integers) Write an application that...Ch. 2 - Which of the following Java statements contain...Ch. 2 - Given that y = ax3 + 7, which of the following are...Ch. 2 - State the order of evaluation of the operators in...Ch. 2 - What does the following code print?...Ch. 2 - What does the following code print?...Ch. 2 - What does the following code print?...Ch. 2 - What does the following code print?...Ch. 2 - (Largest and Smallest Integers) Write an...Ch. 2 - (Odd or Even) Write an application that reads an...Ch. 2 - Write an application that reads two integers,...Ch. 2 - Write an application that displays a checkerboard...Ch. 2 - Circumference and Area of a Circle) Heres a peek...Ch. 2 - (Integer Value of a Character) Heres another peek...Ch. 2 - (Separating the Digits in an Integer) Write an...Ch. 2 - Prob. 25.1ECh. 2 - Prob. 26.1ECh. 2 - (Body Mass Index Calculator) We introduced the...Ch. 2 - (World Population Growth Calculator) Search the...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
A method in a subclass having the same name as a method in the superclass but a different signature is an examp...
Starting Out with Java: From Control Structures through Objects (7th Edition) (What's New in Computer Science)
Distinguish among data definition commands, data manipulation commands, and data control commands.
Modern Database Management
Name the steps in the programming process.
Digital Fundamentals (11th Edition)
Every C++ program must have a function named _____.
Starting Out with C++: Early Objects
Words that have predefined meaning in a programming language are called _____ .
Starting Out With Visual Basic (8th Edition)
(Select a font) Write a program that can dynamically change the font of a text in a label displayed on a stack ...
Introduction to Java Programming and Data Structures, Comprehensive Version (11th 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
- void main (void) { char result = a; for (char i = { 10; i > 5; i = i-1) result = result + i; } // point B } Consider the code above. What is the decimal value of "result" at "point B" if the variable "a" is initially 59?arrow_forwardPlease review the image below. Produce the program in C++. Upload screenshots of Code and Output, as well as the source code. 6arrow_forwardWrite the following function to display three numbers in increasing order:def displaySortedNumbers(num1, num2, num3):Write a test program that prompts the user to enter three numbers and invokes the function to display them in increasing order.arrow_forward
- X15: inOrder Write a function in Java that implements the following logic: Given three ints, a, b , and c,return true if b is greater than a, and c is greater than b.However, with the exception that if bok is true, b does not need to be greater than a.arrow_forwardState whether true or false. The following code will throw an error: double a = 2; double b = 3; int c = a * b;arrow_forwardConsider the following pseudo code, Method func() { PRINT “This is recursive function" func() } Method main( { func() } What will happen when the above snippet is executed?arrow_forward
- PlsHelpASAP Program C int getNum(); /*accepts input from the user.*/ void display(int n1, int n2, int n3, int n4); /*displays the given pattern*/ ----------------------------------------------------------------------------------arrow_forwardDefines and allocates memory for variablesarrow_forward===========Answer question below:=========== - Write program in Java. (Convert infix to postfix) Note: Postfix notation is a way of writing expression without using parentheses. For example, the expression ( 11 + 12 ) * 13 would be written as 11 12 + 13 * Assume that ALWAYS there is a space between operands and operators in the input expression. Use two stacks, one to store the operands and one to store the operators. Your program only accpets following operators : ( ) + - / * Write a method to converts an infix expression into a postfix expression using the following method: String infixToPostfix(String expression) For example, the method should convert the infix expression ( 13 + 25 ) * 34 to 13 25 + 34 * and 20 * ( 10 + 30 ) to 20 10 30 + *. - solution.java: import java.util.*; import java.lang.*; import java.io.*; class InfixToPostfix { public String infixToPostfix(String expression) { } } class DriverMain { public static void main(String args[]) { Scanner input…arrow_forward
- need help in java. (1) Prompt the user for a string that contains two strings separated by a comma. (1 pt) Examples of strings that can be accepted: Jill, Allen Jill , Allen Jill,Allen Ex: Enter input string: Jill, Allen (2) Report an error if the input string does not contain a comma. Continue to prompt until a valid string is entered. Note: If the input contains a comma, then assume that the input also contains two strings. (2 pts)Ex: Enter input string: Jill Allen Error: No comma in string. Enter input string: Jill, Allen (3) Extract the two words from the input string and remove any spaces. Store the strings in two separate variables and output the strings. (2 pts)Ex: Enter input string: Jill, Allen First word: Jill Second word: Allen provided code: import java.util.Scanner; public class ParseStrings { public static void main(String[] args) { Scanner scnr = new Scanner(System.in); /* Type your code here. */ }} (4) Using a loop, extend the program to handle…arrow_forwardWhen you perform arithmetic operations with operands of different types, such as adding an int and a float, ____________. C# chooses a unifying type for the result you must choose a unifying type for the result you must provide a cast you receive an error messagearrow_forwardC Language - Write a program whose inputs are three integers, and whose output is the smallest of the three values.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Control Structures - while loop - do-while loop - for loop - Goto - break - continue statements; Author: EzEd Channel;https://www.youtube.com/watch?v=21l11_9Osd0;License: Standard YouTube License, CC-BY