Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

4 CS136: Computer Science II-Spring 2019 [10 points] Problem #4 A run is a sequence of adjacent repeated values. write a Java class (RunsPrinter. java)

image text in transcribed

4 CS136: Computer Science II-Spring 2019 [10 points] Problem #4 A run is a sequence of adjacent repeated values. write a Java class (RunsPrinter. java) with one main method that generates a sequence of 20 random die tosses in an array (and not an ArrayList) and then prints the die values, marking the runs by including them in parentheses, like this: 1 2 (5 5) 3 124 3 (2 2 2 2) 3 6 (5 5) 6 3 1 Examples of program output: 2(33)56(22) (11) (4444)6142(33)1 (55)43(11)53415152153153 1636(11)46312362565345 Make sure that your code compiles and runs without errors when the following commands are used For compilation javac RunsPrinter.java For execution: java RunsPrinter Hint: Use the following pseudocode algorithm: Set a boolean variable inRun to false. For each valid index i in the ArrayList If inRun If values[i] is different from the preceding value Print) inRun -false If not inRun If values[i] is the same as the following value Print (. inRun - true Print values [i]. If inRun, print )

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advances In Databases And Information Systems 25th European Conference Adbis 2021 Tartu Estonia August 24 26 2021 Proceedings Lncs 12843

Authors: Ladjel Bellatreche ,Marlon Dumas ,Panagiotis Karras ,Raimundas Matulevicius

1st Edition

3030824713, 978-3030824716

More Books

Students also viewed these Databases questions