Exercises 4.10 Compare and contrast the if single-selection statement and the while repetition statement. How are these two statements similar? How are they different?
Exercises 4.10 Compare and contrast the if single-selection statement and the while repetition statement. How are these two statements similar? How are they different?
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
Related questions
Question
Hello Sir. Good Morning.
I have a questions in my homeword related computer
The following below is questions. Please advice. Thank you
![Exercises
4.10
Compare and contrast the if single-selection statement and the while repetition statement.
How are these two statements similar? How are they different?
146
Chapter 4 Control Statements: Part I; Assignment, ++ and
- Operators
4.11
Explain what happens when a Java program attempts to divide one integer by another.
What happens to the fractional part of the calculation? How can you avoid that outcome?
4.12
Describe the two ways in which control statements can be combined.
4.13
What
type of repetition would be appropriate for calculating the sum of the first 100 posi-
tive integers? What type would be appropriate for calculating the sum of an arbitrary number of pos-
itive integers? Briefly describe how each of these tasks could be performed.
4.14
What is the difference between preincrementing and postincrementing a variable?
4.15
Identify and correct the errors in each of the following pieces of code. [Note: There :
may
be
more than one error in each piece of code.]
a) if (age >= 65);
System.out.println("Age is greater than or equal to 65");
else
System.out.println("Age is less than 65)";
b) int x = 1, total;
while (x <= 10)
{
total += x;
++x;
}
c) while (x <= 100)
total += x;
++x;
d) while (y > 0)
{
System.out.println(y);
++y;
4.16
What does the following program print?
// Exercise 4.16: Mystery.java
2
public class Mystery
3
{
public static void main(String[] args)
{
int x = 1;
int total = 0;
7
8
9
while (x <= 10)
10
II
int y = x * x;
System.out.println(y);
total += y;
12
13
14
++X;
15
}
16
17
System.out.printf("Total is %d%n", total);
}
} // end class Mystery
18
19](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fee789098-4905-4a95-b835-85874aef6f66%2F10e04d4f-5f2f-4ee8-8c59-b7f22c81faf7%2Foj1zfb_processed.jpeg&w=3840&q=75)
Transcribed Image Text:Exercises
4.10
Compare and contrast the if single-selection statement and the while repetition statement.
How are these two statements similar? How are they different?
146
Chapter 4 Control Statements: Part I; Assignment, ++ and
- Operators
4.11
Explain what happens when a Java program attempts to divide one integer by another.
What happens to the fractional part of the calculation? How can you avoid that outcome?
4.12
Describe the two ways in which control statements can be combined.
4.13
What
type of repetition would be appropriate for calculating the sum of the first 100 posi-
tive integers? What type would be appropriate for calculating the sum of an arbitrary number of pos-
itive integers? Briefly describe how each of these tasks could be performed.
4.14
What is the difference between preincrementing and postincrementing a variable?
4.15
Identify and correct the errors in each of the following pieces of code. [Note: There :
may
be
more than one error in each piece of code.]
a) if (age >= 65);
System.out.println("Age is greater than or equal to 65");
else
System.out.println("Age is less than 65)";
b) int x = 1, total;
while (x <= 10)
{
total += x;
++x;
}
c) while (x <= 100)
total += x;
++x;
d) while (y > 0)
{
System.out.println(y);
++y;
4.16
What does the following program print?
// Exercise 4.16: Mystery.java
2
public class Mystery
3
{
public static void main(String[] args)
{
int x = 1;
int total = 0;
7
8
9
while (x <= 10)
10
II
int y = x * x;
System.out.println(y);
total += y;
12
13
14
++X;
15
}
16
17
System.out.printf("Total is %d%n", total);
}
} // end class Mystery
18
19
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 4 steps

Recommended textbooks for you

Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON

Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science

Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning

Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON

Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science

Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning

Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning

Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education

Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY