Absolute Java (6th Edition)
Absolute Java (6th Edition)
6th Edition
ISBN: 9780134041674
Author: Walter Savitch, Kenrick Mock
Publisher: PEARSON
Expert Solution & Answer
Book Icon
Chapter 3, Problem 34STE

Explanation of Solution

Given: The lines of Java code:

int n, m;

for (n = 1; n <= 10; n++)

for (m = 10; m >= 1; m--)

System.out.println(n + " times " + m+ " = " + n*m);

To find: The output of the lines of code in Java language and comment on the code:

int n, m;

for (n = 1; n <= 10; n++)

for (m = 10; m >= 1; m--)

System.out.println(n + " times " + m+ " = " + n*m);

Solution:

In this code:

Two variables, m and n, are declared.

In the outer for loop, the variable n will increment from 1 to 10 in ascending order and variable m in the inner for loop will decrement from 10 to 1.

In the outer loop, the value of n iterates from 1 and gets incremented by 1 if n<=10.

Then, it moves to the inner loop in which the value of m iterates from 10 and gets decremented by 1 till m>=1.

For every value of n, the inner loop repeats itself till the condition of m>=1 is satisfied and it executes the print statement for every value of m...

Blurred answer
Students have asked these similar questions
How many time will the loop run?   for( int i = 18 ; i < 65 ; i++ )  {    }
Consider the following for loop. int j, s;s = 0;for (j = 1; j <= 10; j++)s = s + j * (j - 1);In this for loop, identify the loop control variable, the initialization statement, loop condition, the update statement, and the statement that updates the value of s.
Convert the code below to use a for loop instead of a while loop.     int num1 = 1; int num2 = 1; int num3 = 5;   while (num1 < num3) { num2 = num1 * num2; System.out.println("num2: " + num2); num1++; }   System.out.println("num1: " + num1);   Java

Chapter 3 Solutions

Absolute Java (6th Edition)

Ch. 3 - Prob. 11STECh. 3 - Prob. 12STECh. 3 - Prob. 13STECh. 3 - Suppose are two variables that have been given...Ch. 3 - Prob. 15STECh. 3 - Assume that nextword is a String variable that has...Ch. 3 - Write an if-else statement that outputs the word...Ch. 3 - Write an if-else statement that outputs the word...Ch. 3 - Determine the value, true or false, of each of the...Ch. 3 - Does the following sequence produce a division by...Ch. 3 - Prob. 21STECh. 3 - Prob. 22STECh. 3 - What output would be produced in Self-Test...Ch. 3 - What is the output produced by the following? Ch. 3 - What output would be produced in Self-Test...Ch. 3 - Prob. 26STECh. 3 - What is the most important difference between a...Ch. 3 - Prob. 28STECh. 3 - Prob. 29STECh. 3 - What is the output of the following? Ch. 3 - Rewrite the following for statement as a while...Ch. 3 - What is the output of the following loop? Identify...Ch. 3 - What is the output of the following loop? Comment...Ch. 3 - Prob. 34STECh. 3 - For each of the following situations, tell which...Ch. 3 - What is the output of the following? Ch. 3 - What is the output of the following? Ch. 3 - What is the output produced by the following?...Ch. 3 - What is the output produced by the following?...Ch. 3 - Fix the bug in the code in the earlier subsection...Ch. 3 - Add some suitable output statements to the...Ch. 3 - What is the bug in the following code? What do you...Ch. 3 - Prob. 43STECh. 3 - What numbers could be generated by...Ch. 3 - What numbers could be generated by...Ch. 3 - Use the method Math. random to generate a random...Ch. 3 - (This is a version of Programming Project 2.1 from...Ch. 3 - A designer is trying to create a new pattern of...Ch. 3 - Weight is defined as the gravitational force...Ch. 3 - It is difficult to make a budget that spans...Ch. 3 - You have just purchased a stereo system that cost ...Ch. 3 - The Fibonacci numbers Fn are defined as follows:...Ch. 3 - An Armstrong number is an n-digit number that...Ch. 3 - In a certain code language, numerals are each...Ch. 3 - Write a program that calculates the total grade...Ch. 3 - The game of Pig is a simple two-player dice game...Ch. 3 - You have three identical prizes to give away and a...Ch. 3 - Redo or do for the first time Programming Project...Ch. 3 - The file words. txt on the hook's website contains...Ch. 3 - The file words. txt on the book's website contains...Ch. 3 - This problem is based on a "Nifty Assignment" by...Ch. 3 - Prob. 16PP
Knowledge Booster
Background pattern image
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