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
Concept explainers
Textbook Question
Chapter 4.5, Problem 4.5.3CP
What would be wrong if lines 6 and 7 are in Listing 4.5 replaced by the following code?
String lottery= "" + (int)(Math.random() * 100);
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
What is the output of the following code fragment?
int n = 1;
while (n <= 5)
cout << n << ' ';
n++;
string of three names print each name in a new line? (separate every word in new line)
For the following code fragment, what is the value of the variable b at the end?
int a = 0;
int b = 3;int c = 2;while ( a < 5 ){ a = a + 1; b += 3;continue;c = c * 2; }
Chapter 4 Solutions
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
Ch. 4.2 - Evalute the following method calls: (a)...Ch. 4.2 - True or false? The argument for trigonometric...Ch. 4.2 - Write a statement that converts 47 degrees to...Ch. 4.2 - Write a statement that converts PI to an angle in...Ch. 4.2 - Write an expression that obtains a random integer...Ch. 4.2 - Prob. 4.2.6CPCh. 4.2 - Prob. 4.2.7CPCh. 4.3 - Use print statements to find out the ASCII code...Ch. 4.3 - Which of the following are correct literals for...Ch. 4.3 - How do you display the characters \ and "?
Ch. 4.3 - Evaluate the following: Int i = '1'; int j ='1' +...Ch. 4.3 - Can the following conversions involving casting be...Ch. 4.3 - Show the output of the following program: public...Ch. 4.3 - Write the code that generates a random lowercase...Ch. 4.3 - Show the output of the following statements:...Ch. 4.4 - Suppose s1, s2, and s3 are three strings, given as...Ch. 4.4 - Prob. 4.4.2CPCh. 4.4 - Show the output of the following statements (write...Ch. 4.4 - Prob. 4.4.4CPCh. 4.4 - Let s1 be " Welcome " and s2 be " welcome ". Write...Ch. 4.4 - Write one statement to return the number of digits...Ch. 4.4 - Write one statement to return the number of digits...Ch. 4.5 - If you run Listing 4.3 GuessBirthday.java with...Ch. 4.5 - If you enter a lowercase letter such as b, the...Ch. 4.5 - What would be wrong if lines 6 and 7 are in...Ch. 4.6 - Prob. 4.6.1CPCh. 4.6 - Prob. 4.6.2CPCh. 4.6 - Show the output of the following statements: (a)...Ch. 4 - (Geometry: area of a pentagon) Write a program...Ch. 4 - (Geometry: great circle distance) The great circle...Ch. 4 - (Geography: estimate areas) Use the GPS locations...Ch. 4 - (Geometry: area of a hexagon) The area of a...Ch. 4 - (Geometry: area of a regular polygon) A regular...Ch. 4 - (Random points on a circle) Write a program that...Ch. 4 - (Corner point coordinates) Suppose a pentagon is...Ch. 4 - (Find the character of an ASCII code) Write a...Ch. 4 - (Find the Unicode of a character) Write a program...Ch. 4 - (Guess birthday) Rewrite Listing 4.3,...Ch. 4 - (Decimal to hex) Write a program that prompts the...Ch. 4 - (Hex to binary) Write a program that prompts the...Ch. 4 - (Vowel or consonant?) Write a program that prompts...Ch. 4 - (Convert Letter grade to number) Write a program...Ch. 4 - (Phone key pads) The international standard...Ch. 4 - (Random character) Write a program that displays a...Ch. 4 - (Days of a month) Write a program that prompts the...Ch. 4 - (Student major and status) Write a program that...Ch. 4 - (Business: check ISBN-10) Rewrite Programming...Ch. 4 - (Process a string) Write a program that prompts...Ch. 4 - (Check SSN) Write a program that prompts the user...Ch. 4 - (Check substring) Write a program that prompts the...Ch. 4 - 23 (Financial application: payroll) Write a...Ch. 4 - (Order three cities) Write a program that prompts...Ch. 4 - (Generate vehicle plate numbers) Assume that a...Ch. 4 - (Financial application: monetary units) Rewrite...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
a. What Boolean operation does the circuit compute? b. What Boolean operation does the circuit compute?
Computer Science: An Overview (13th Edition) (What's New in Computer Science)
Account Balance A program that calculates the current balance in a savings account must ask the user for the fo...
Starting Out with Java: From Control Structures through Objects (7th Edition) (What's New in Computer Science)
Write a simple assignment statement with one arithmetic operator in some language you know. For each component ...
Concepts of Programming Languages (11th Edition)
the variable die1.
Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
You can use the __________ property to determine whether an item is selected in a ListBox. a. Index b. Selected...
Starting out with Visual C# (4th Edition)
Identify each of the following expressions as SOP, standard SOP, POS, or standard POS a.AB+ABD+ACDb.(A+B+C)(A+B...
Digital Fundamentals (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
- Consider the following statement:int* p, q;This statement could lead to what type of misinterpretation?arrow_forwardwhat will be the output? #include int main () {int i = 3; i++; print ("%d", i); i--; print ("%d", i); return 0;} a. 34, b. 33, c. 44, d. 43arrow_forwardWhat is the printout of the following code segment? void fun(int *a) { *a *= 2; }int main() { int b = 3; fun(&b); cout << b; return 0; } A. 2 B. 3 C. 4 D. 6arrow_forward
- Consider the following code: public static void test_b(int n) { if (n>0) test_b(n-2); System.out.println(n + " "); } What is printed by the call test_b(6)?arrow_forwardAssume int[][] x = {{1, 2}, {3, 4}, {5, 6}}, what are x.length are x[0].length? 5 3 and 2 4 2 and 1 3 2 and 3 2 2 and 2 1 3 and 3arrow_forwardWhat is output by the following code segment? char string1[] = "How are you?";for ( int i = 0; i <6; i++ ) cout << string1[ i ] << "_"; Group of answer choices H o w a r e How are you? H o w a r e y o u ? H o w a rarrow_forward
- What is the output of the code segment below? Hint: Draw a 2x3 grid and then fill it in. int[][] plot = new int[2][3]; for (int s = 0; s < 2; s++) for (int t = 0; t < 3; t++) plot[s][t] = t - s + 3; for (int s = 0; s < 2; s++) { int sum = 0; for (int t = 0; t < 3; t++) sum += plot[s][t]; System.out.print(sum + " "); }arrow_forwardWhat will the following code display?arrow_forwardWhat will be the value of x[8] after the following code is executed? final int NUM = 10;int[] x = new int[NUM];int y = 1;for (int i = 0; i < NUM; i++){x[i] = y;y++;} 1 9 7 5arrow_forward
- What will the following program display?arrow_forwardWhat is the value of x after the following code executes? double m = 2.67;int x = (int)m;arrow_forwardI want to create a program called Guests.java that prompts a user to enter how many guests he will host. Next, reads a series of the names into an array of Strings using Scanner, and then prints back "Welcome" to each of those guests. Output should be as picture showsarrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Control Structure in Data Structure - Data Structures - Computer Science Class 12; Author: Ekeeda;https://www.youtube.com/watch?v=9FTw2pXLhv4;License: Standard YouTube License, CC-BY