The plain-text file "SeguencesTest" contains the skeleton of a program. It is missing some lines in different places, which you must add. (Hint: if you think about this a bit before starting, you The final output will look something like this: The longest sequence starts at 27 and has length 44 will probably add less than 10-15 lines of code to what is here.) The highest value sequence starts at 53 and has the high Purpose of Program value 100 As it is written in the starter file, the program takes a number (n) and processes it through the while loop. It is complete when the value of n reaches 1. (No input or output statements are The values shown here are for demonstration only and are not even close to the correct answers. in this starter file.) Do not print out the intermediate values in the series. You are to print only the two lines, with As it is shown in the starter file, the program would normally print out the value it started with the appropriate values in them, as described above. and the length of the sequence of numbers it went through to reach 1. In other words, it takes HINT: Use long, not int, for all of your variables. one value for n and processes it, producing a series (or sequence) of numbers. For example, using the supplied program, output using the start value of 51 would look like: The sequence starting at 51 has length 25 This tells us that if we run the starter program (and add the necessary output statements), it would take 25 steps (or values in the sequence) to reach 1. What You Must Do Your task is to add any necessary variables, control flow structures, and output statements to show the following: Test all possible input values between 1 and 500,000 (including those two values). You are looking for two sequences: one with the longest sequence of numbers of any of the sequences, and one with the highest value reached of any value in any of the sequences. At end of the program, with appropriate messages, show: o the starting value and the length (number of values) of the longest sequence in the series, and o the starting value of the sequence with the highest value reached in the series with the high value itself.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

The Code must be in Java 

The plain-text file "SeguencesTest" contains the skeleton of a program. It is missing some lines
in different places, which you must add. (Hint: if you think about this a bit before starting, you
The final output will look something like this:
The longest sequence starts at 27 and has length 44
will probably add less than 10-15 lines of code to what is here.)
The highest value sequence starts at 53 and has the high
Purpose of Program
value 100
As it is written in the starter file, the program takes a number (n) and processes it through the
while loop. It is complete when the value of n reaches 1. (No input or output statements are
in this starter file.)
The values shown here are for demonstration only and are not even close to the correct
answers.
Do not print out the intermediate values in the series. You are to print only the two lines, with
As it is shown in the starter file, the program would normally print out the value it started with
the appropriate values in them, as described above.
and the length of the sequence of numbers it went through to reach 1. In other words, it takes
HINT: Use long, not int, for all of your variables.
one value for n and processes it, producing a series (or sequence) of numbers.
For example, using the supplied program, output using the start value of 51 would look like:
The sequence starting at 51 has length 25
This tells us that if we run the starter program (and add the necessary output statements), it
would take 25 steps (or values in the sequence) to reach 1.
What You Must Do
Your task is to add any necessary variables, control flow structures, and output statements to
show the following:
Test all possible input values between 1 and 500,000 (including those two values).
You are looking for two sequences:
one with the longest sequence of numbers of any of the sequences, and
one with the highest value reached of any value in any of the sequences.
At end of the program, with appropriate messages, show:
o the starting value and the length (number of values)
the series, and
the longest sequence in
the starting value of the sequence with the highest value reached in the series
with the high value itself.
Transcribed Image Text:The plain-text file "SeguencesTest" contains the skeleton of a program. It is missing some lines in different places, which you must add. (Hint: if you think about this a bit before starting, you The final output will look something like this: The longest sequence starts at 27 and has length 44 will probably add less than 10-15 lines of code to what is here.) The highest value sequence starts at 53 and has the high Purpose of Program value 100 As it is written in the starter file, the program takes a number (n) and processes it through the while loop. It is complete when the value of n reaches 1. (No input or output statements are in this starter file.) The values shown here are for demonstration only and are not even close to the correct answers. Do not print out the intermediate values in the series. You are to print only the two lines, with As it is shown in the starter file, the program would normally print out the value it started with the appropriate values in them, as described above. and the length of the sequence of numbers it went through to reach 1. In other words, it takes HINT: Use long, not int, for all of your variables. one value for n and processes it, producing a series (or sequence) of numbers. For example, using the supplied program, output using the start value of 51 would look like: The sequence starting at 51 has length 25 This tells us that if we run the starter program (and add the necessary output statements), it would take 25 steps (or values in the sequence) to reach 1. What You Must Do Your task is to add any necessary variables, control flow structures, and output statements to show the following: Test all possible input values between 1 and 500,000 (including those two values). You are looking for two sequences: one with the longest sequence of numbers of any of the sequences, and one with the highest value reached of any value in any of the sequences. At end of the program, with appropriate messages, show: o the starting value and the length (number of values) the series, and the longest sequence in the starting value of the sequence with the highest value reached in the series with the high value itself.
*SequencesTest - Notepad
File Edit Format View Help
"SequencesTest"
public class SequencesTest {
public static void main(String[] args) {
long nsave = n;
long count
while (n != 1) {
if (n%2
0;
0) {
n = n / 2;
==
}
else {
n = 3 * n + 1;
}
count ++;
}
}
}
Transcribed Image Text:*SequencesTest - Notepad File Edit Format View Help "SequencesTest" public class SequencesTest { public static void main(String[] args) { long nsave = n; long count while (n != 1) { if (n%2 0; 0) { n = n / 2; == } else { n = 3 * n + 1; } count ++; } } }
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Function Arguments
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
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education