This game requests six dice numbers from the player. The game then throws the dice until that pattern appears. The game then tells the player how many throws it took. Please enter the six-number pattern you would like the computer to throw separated by spaces. 123456 yes it took 33,012 throws to get the pattern 1 2 3 4 5 6 Would you like to play the game again? Please enter (yes/no) Please enter the six-number pattern you would like the computer to throw separated by spaces. 666666 it took 338,136 throws to get the pattern 6 66

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
icon
Concept explainers
Question

I need help fixing my Java code to have an output that is displayed on the given image:

Java Code:

 

import java.util.Random;
import java.util.Scanner;
class Pattern_of_six_FallProject_3

    public static void main(String[] args) { 

        
        
        while(true){    
            String pattern = getInputPattern();  
            int count = getCountToGetPattern(pattern);  
            System.out.println("it took " + count + " throws to get the pattern" + pattern); 
            if (repeatAgain()==false) 

            break;      
        }   
    }     

    private static String getInputPattern() 
    {    
        Scanner input=new Scanner(System.in);       

        System.out.println("Please enter the six number pattern you would like the computer to throw seperated by spaces");    

        String pattern=input.nextLine();       

        return pattern+" ";   
    }    

    private static int getCountToGetPattern(String pattern) {    

        Random rand=new Random();     
        String outputPattern="";      

            for(int i=0;i<6;i++)          
            outputPattern += ""+1+rand.nextInt(6) ;   

            int count=1;       

            while(! outputPattern.equals(pattern))    
            {         

                outputPattern="";     

                for(int i=0;i<6;i++)     
                outputPattern += 1+rand.nextInt(6) +" ";    

                count++;       
            }       
            return count;
            }     
            private static boolean repeatAgain()   
            {        
                Scanner input=new Scanner(System.in);     
                System.out.println("Would you like to play the game again? Please enter (yes/no)"); 
                if(input.next().equals("yes"))          
                return true;       
                else          
                return false; 
            }
     } 

This game requests six dice numbers from the player.
The game then throws the dice until that pattern appears.
The game then tells the player how many throws it took.
Please enter the six-number pattern you would
like the computer to throw separated by spaces.
123456
yes
it took 33,012 throws to get the pattern 123456
Would you like to play the game again?
Please enter (yes/no)
Please enter the six-number pattern you would
like the computer to throw separated by spaces.
666666
it took 338,136 throws to get the pattern 6 6 6 6 6 6
Transcribed Image Text:This game requests six dice numbers from the player. The game then throws the dice until that pattern appears. The game then tells the player how many throws it took. Please enter the six-number pattern you would like the computer to throw separated by spaces. 123456 yes it took 33,012 throws to get the pattern 123456 Would you like to play the game again? Please enter (yes/no) Please enter the six-number pattern you would like the computer to throw separated by spaces. 666666 it took 338,136 throws to get the pattern 6 6 6 6 6 6
Expert Solution
steps

Step by step

Solved in 4 steps with 3 images

Blurred answer
Knowledge Booster
Control Structure
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