MINDTAPV2.0 JAVA PROGRAMMING 2021, 1TERM
MINDTAPV2.0 JAVA PROGRAMMING 2021, 1TERM
9th Edition
ISBN: 9780357505526
Author: FARRELL
Publisher: CENGAGE L
bartleby

Concept explainers

Expert Solution & Answer
Book Icon
Chapter 9, Problem 1PE

a.

Explanation of Solution

Program:

File name: “StringSort.java

//Import necessary header files

import java.util.*;

import javax.swing.*;

//Define a class named StringSort

public class StringSort

{

    //Define main method

    public static void main(String[] args)

    {

        //Create an array of 15 string values

String[] values =  {"mouse", "dog", "cat", "horse", "cow",

         "moose", "tiger", "lion", "elephant", "bird", "hamster",

         "guina pig", "leopard", "aardvark", "hummingbird"};

        //Declare the variable

      ...

b.

Explanation of Solution

Program:

File name: “StringSort2.java

//Import necessary header files

import java.util.*;

import javax.swing.*;

//Define a class named StringSort2

public class StringSort2

{

    //Define main method

    public static void main(String[] args)

    {

        //Create an array of 15 string values

        String[] values = new String[15];

        //Declare the variables and initialize the values

        int x = 0;

        int count = 0;

        String word;

        final String QUIT = "zzz";

        //Declare a Boolean variable and initialize the value

        boolean didUserQuit = false;

/*For loop is executed until x exceeds the length of the given values*/

        for(x = 0; x < values.length; ++x)

            values[x] = QUIT;

        //Assign value 0 to x

        x = 0;

        //While x is less than the length of the given values

        while(x < values.length)

        {

            //Prompt the user to enter a word

word = JOptionPane.showInputDialog(null, "Enter a word or " +

            QUIT + " to quit");

            //If the user enters zzz

            if(word.equals(QUIT))

            {

                count = x;

                x = values...

Blurred answer
Students have asked these similar questions
Modular Program Structure. Analysis of Structured Programming Examples. Ways to Reduce Coupling. Based on the given problem, create an algorithm and a block diagram, and write the program code: Function: y=xsin⁡x Interval: [0,π] Requirements: Create a graph of the function. Show the coordinates (x and y). Choose your own scale and show it in the block diagram. Create a block diagram based on the algorithm. Write the program code in Python. Requirements: Each step in the block diagram must be clearly shown. The graph of the function must be drawn and saved (in PNG format). Write the code in a modular way (functions and the main part should be separate). Please explain and describe the results in detail.
Based on the given problem, create an algorithm and a block diagram, and write the program code: Function: y=xsin⁡x Interval: [0,π] Requirements: Create a graph of the function. Show the coordinates (x and y). Choose your own scale and show it in the block diagram. Create a block diagram based on the algorithm. Write the program code in Python. Requirements: Each step in the block diagram must be clearly shown. The graph of the function must be drawn and saved (in PNG format). Write the code in a modular way (functions and the main part should be separate). Please explain and describe the results in detail.
Based on the given problem, create an algorithm and a block diagram, and write the program code: Function: y=xsin⁡x Interval: [0,π] Requirements: Create a graph of the function. Show the coordinates (x and y). Choose your own scale and show it in the block diagram. Create a block diagram based on the algorithm. Write the program code in Python. Requirements: Each step in the block diagram must be clearly shown. The graph of the function must be drawn and saved (in PNG format). Write the code in a modular way (functions and the main part should be separate). Please explain and describe the results in detail.
Knowledge Booster
Background pattern image
Computer Science
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
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Text book image
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:9781337102124
Author:Diane Zak
Publisher:Cengage Learning
Text book image
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781305480537
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning