Please write the script and introduction for the program so that the number of words is between 300-400 //importing scanner import java.util.Scanner;   //our main class public class Main {         //our main method         public static void main(String args[])     {                 //declaring pegs                 int pegs;                 //declaring source,destination,middleone strings                 String source,destination,middleone;                 //creating scanner class                 Scanner mine = new Scanner(System.in);                 //asking number of pegs                 System.out.print("Please enter the number of pegs: ");                 //user input                 pegs=mine.nextInt();                 //to the nextline                 mine.nextLine();                 //printing                 System.out.print("Please enter the source name: ");                 //user input                 source=mine.nextLine();                 //printing                 System.out.print("Please enter the destination name: ");                 //user input                 destination=mine.nextLine();                 //printing                 System.out.print("Please enter the middle_one name: ");                 //user input                 middleone=mine.nextLine();                 //printing new line                 System.out.println("\n\n");                                                 //calling our function Towers_of_Hanoi                 Towers_of_Hanoi(pegs,source,destination,middleone);                 //closing scanner class         mine.close();     }           //our recursive function Towers of Hanoi     public static void Towers_of_Hanoi(int pegs, String source, String destination, String middle_one)     {         //if condition         if(pegs==1){                 //printing             System.out.println("MOVE Disc 1 from bar " +  source + " to bar " + destination);             //return statement             return;         }         //calling Towers_of_Hanoi function         Towers_of_Hanoi(pegs-1, source, middle_one, destination);         //printing         System.out.println("MOVE Disc " + pegs + " from bar " +  source + " to bar " + destination);         //calling Towers_of_Hanoi function         Towers_of_Hanoi(pegs-1, middle_one, destination, source);     }               }

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

Please write the script and introduction for the program so that the number of words is between 300-400

//importing scanner

import java.util.Scanner;

 

//our main class

public class Main {

        //our main method

        public static void main(String args[])

    {

                //declaring pegs

                int pegs;

                //declaring source,destination,middleone strings

                String source,destination,middleone;

                //creating scanner class

                Scanner mine = new Scanner(System.in);

                //asking number of pegs

                System.out.print("Please enter the number of pegs: ");

                //user input

                pegs=mine.nextInt();

                //to the nextline

                mine.nextLine();

                //printing

                System.out.print("Please enter the source name: ");

                //user input

                source=mine.nextLine();

                //printing

                System.out.print("Please enter the destination name: ");

                //user input

                destination=mine.nextLine();

                //printing

                System.out.print("Please enter the middle_one name: ");

                //user input

                middleone=mine.nextLine();

                //printing new line

                System.out.println("\n\n");

               

               

                //calling our function Towers_of_Hanoi

                Towers_of_Hanoi(pegs,source,destination,middleone);

                //closing scanner class

        mine.close();

    }

 

        //our recursive function Towers of Hanoi

    public static void Towers_of_Hanoi(int pegs, String source, String destination, String middle_one)

    {

        //if condition

        if(pegs==1){

                //printing

            System.out.println("MOVE Disc 1 from bar " +  source + " to bar " + destination);

            //return statement

            return;

        }

        //calling Towers_of_Hanoi function

        Towers_of_Hanoi(pegs-1, source, middle_one, destination);

        //printing

        System.out.println("MOVE Disc " + pegs + " from bar " +  source + " to bar " + destination);

        //calling Towers_of_Hanoi function

        Towers_of_Hanoi(pegs-1, middle_one, destination, source);

    }

   

   

 

   

}

 

O eclipse workspace - Eclipse IDE
File Edit Navigate Search Project Run Window Help
4. Package Explorer
Amays
Console 1JMainjava
<terminated> Main (2) [Aava Application) CAProgram Files Javaljdk-13.0.1binljavaw.exe Jun 5, 2021, 121803 PM)
Please enter the number of pegs: 4
Please enter the source name: Tower Source
Karatet
Main
R JRE System Library JavaSE-131
Please enter the destination name: Tower_Destination
Please enter the middle one name: Tower_Middle
* (default package)
J Final3java
J TheSamejava
J Mainjava
J MidtermProblemsjava
J Moonjava
d. myQuizjava
J Penciljava
J petsjava
J Receiptjava
J StudentTest.java
J. TestScores.java
J Ublsjava
MOVE Disc 1 from bar Tower_Source to bar Tower_Middle
MOVE Disc 2 from bar Tower Source to bar Tower Destination
MOVE Disc 1 from bar Tower Middle to bar Tower Destination
MOVE Disc 3 from bar Tower Source to bar Tower Middle
MOVE Disc 1 from bar Tower Destination to bar Tower_Source
MOVE Disc 2 from bar Tower Destination to bar Tower_Middle
MOVE Disc 1 from bar Tower Source to bar Tower Middle
MOVE Disc 4 from bar Tower Source to bar Tower Destination
MOVE Disc 1 from bar Tower_Middle to bar Tower Destination
MOVE Disc 2 from bar Tower_Middle to bar Tower_Source
MOVE Disc 1 from bar Tower Destination to bar Tower_Source
MOVE Disc 3 from bar Tower_Middle to bar Tower Destination
MOVE Disc 1 from bar Tower Source to bar Tower Middle
MOVE Disc 2 from bar Tower_Source to bar Tower Destination
MOVE Disc 1 from bar Tower_Middle to bar Tower Destination
mine
Ouotes
ww
155M of5EM
Transcribed Image Text:O eclipse workspace - Eclipse IDE File Edit Navigate Search Project Run Window Help 4. Package Explorer Amays Console 1JMainjava <terminated> Main (2) [Aava Application) CAProgram Files Javaljdk-13.0.1binljavaw.exe Jun 5, 2021, 121803 PM) Please enter the number of pegs: 4 Please enter the source name: Tower Source Karatet Main R JRE System Library JavaSE-131 Please enter the destination name: Tower_Destination Please enter the middle one name: Tower_Middle * (default package) J Final3java J TheSamejava J Mainjava J MidtermProblemsjava J Moonjava d. myQuizjava J Penciljava J petsjava J Receiptjava J StudentTest.java J. TestScores.java J Ublsjava MOVE Disc 1 from bar Tower_Source to bar Tower_Middle MOVE Disc 2 from bar Tower Source to bar Tower Destination MOVE Disc 1 from bar Tower Middle to bar Tower Destination MOVE Disc 3 from bar Tower Source to bar Tower Middle MOVE Disc 1 from bar Tower Destination to bar Tower_Source MOVE Disc 2 from bar Tower Destination to bar Tower_Middle MOVE Disc 1 from bar Tower Source to bar Tower Middle MOVE Disc 4 from bar Tower Source to bar Tower Destination MOVE Disc 1 from bar Tower_Middle to bar Tower Destination MOVE Disc 2 from bar Tower_Middle to bar Tower_Source MOVE Disc 1 from bar Tower Destination to bar Tower_Source MOVE Disc 3 from bar Tower_Middle to bar Tower Destination MOVE Disc 1 from bar Tower Source to bar Tower Middle MOVE Disc 2 from bar Tower_Source to bar Tower Destination MOVE Disc 1 from bar Tower_Middle to bar Tower Destination mine Ouotes ww 155M of5EM
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

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