Put a box around your answers for the outputs. Determine the output for #1 - 5. 1. int i = 2; while (i < 10) System.out.printIn(i): 2. int i = 2; while (i < 15) i= i+ 2; System.out.printin(i): 3. int i = 5; for (int j = 1; j < 7; j++) ·

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter5: Control Structures Ii (repetition)
Section: Chapter Questions
Problem 20PE: When you borrow money to buy a house, a car, or for some other purpose, you repay the loan by making...
icon
Related questions
Question
Put a box around your answers for the outputs.
Determine the output for #1 - 5,
1. int i = 2;
while (i < 10)
i++;
System.out.printIn(i):
2. int i = 2;
while (i < 15)
i= i+ 2;
System.out.printin(i);
3. int i = 5;
for (int j = 1; j < 7; j++)
i=i- 2;
System.out.print(*i = " + i + "and j = ");
System.out.printin( j );
4. for (int i = 5; i > 0; i = i - 1)
System.out.print( "yes");
5. int total : 4;
int i = 2;
while (i < 5)
total = total * i;
is i+ 1;
System.out.printIn("The total is " + total);
6. Rewrite #5 above using a for loop instead of a while loop.
Transcribed Image Text:Put a box around your answers for the outputs. Determine the output for #1 - 5, 1. int i = 2; while (i < 10) i++; System.out.printIn(i): 2. int i = 2; while (i < 15) i= i+ 2; System.out.printin(i); 3. int i = 5; for (int j = 1; j < 7; j++) i=i- 2; System.out.print(*i = " + i + "and j = "); System.out.printin( j ); 4. for (int i = 5; i > 0; i = i - 1) System.out.print( "yes"); 5. int total : 4; int i = 2; while (i < 5) total = total * i; is i+ 1; System.out.printIn("The total is " + total); 6. Rewrite #5 above using a for loop instead of a while loop.
7. Complete the code:
public class Test
{
public static void main(String[ ] args)
{
int i = 4; intj = 5;
// Fill in the code to invoke the sum method and display the sum of i and j.
public static int sum(int i, int j)
{
// Fill in the code here to return the sum of i and j.
8. Complete the code:
public class Test
{
public static void main(String (] args)
{
int i = 4; int j = 5;
// Fill in the code to invoke the printSum method to display the sum of i and j.
public static void printSum(int i, int j)
{
// Fill in the code here to display the sum of i and j.
Transcribed Image Text:7. Complete the code: public class Test { public static void main(String[ ] args) { int i = 4; intj = 5; // Fill in the code to invoke the sum method and display the sum of i and j. public static int sum(int i, int j) { // Fill in the code here to return the sum of i and j. 8. Complete the code: public class Test { public static void main(String (] args) { int i = 4; int j = 5; // Fill in the code to invoke the printSum method to display the sum of i and j. public static void printSum(int i, int j) { // Fill in the code here to display the sum of i and j.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning