Create a Java application NumberLoops and complete the main) method according to the following pseudocode.

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...
icon
Related questions
Question
NO nest loop
Q Search
Page 2 of 4
Problem B
Create a Java application NumberLoops and complete the main() method according to the
following pseudocode.
Ask for a positive integer using prompt “Enter a positive integer: "
If the input is not an integer
Get the input
Display a message
Sample output assuming the input “java"
"Not an integer: java"
Terminate the program
Input the integer and store it in a variable
If the input is not positive
Display a message
Sample output assuming the input “-4"
"Not positive: -4"
Terminate the program
Declare a double variable with initial value of 1.0
Use a for loop to calculate the product of all positive integers
that are less than the input number and are multiple of 3
and store the result in the double variable
Display the product as an integer
Sample output assuming the input “30"
"The product is 7142567040"
Display the following message on one line
"All non-negative integers less than the input integer:"
Use a for loop to display all non-negative integers less than the input integer
Transcribed Image Text:Q Search Page 2 of 4 Problem B Create a Java application NumberLoops and complete the main() method according to the following pseudocode. Ask for a positive integer using prompt “Enter a positive integer: " If the input is not an integer Get the input Display a message Sample output assuming the input “java" "Not an integer: java" Terminate the program Input the integer and store it in a variable If the input is not positive Display a message Sample output assuming the input “-4" "Not positive: -4" Terminate the program Declare a double variable with initial value of 1.0 Use a for loop to calculate the product of all positive integers that are less than the input number and are multiple of 3 and store the result in the double variable Display the product as an integer Sample output assuming the input “30" "The product is 7142567040" Display the following message on one line "All non-negative integers less than the input integer:" Use a for loop to display all non-negative integers less than the input integer
Each number must be displayed with a length of 3, and each line has ten numbers unless the last
line. See the sample runs below.
Sample Run #1
Enter a positive integer: -4
Not positive: -4
Sample Run #2
Enter a positive integer: 27
The product is 264539520.
All non-negative integers less than the input integer:
1
2 3
4
5 6 7 8 9
10 11 12 13 14 15 16 17 18 19
20 21 22 23 24 25 26
You must use a for loop to calculate the product and another for loop to display the numbers.
No nested loops.
Hint: Use the modulus operator to go to the next line.
Hint: Use the format specifier “%.0f' to display the double product as an integer.
Magic numbers are allowed for this problem.
Transcribed Image Text:Each number must be displayed with a length of 3, and each line has ten numbers unless the last line. See the sample runs below. Sample Run #1 Enter a positive integer: -4 Not positive: -4 Sample Run #2 Enter a positive integer: 27 The product is 264539520. All non-negative integers less than the input integer: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 You must use a for loop to calculate the product and another for loop to display the numbers. No nested loops. Hint: Use the modulus operator to go to the next line. Hint: Use the format specifier “%.0f' to display the double product as an integer. Magic numbers are allowed for this problem.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 5 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
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 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)
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
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY