Java Programming
Java Programming
8th Edition
ISBN: 9781305981829
Author: Joyce Farrell
Publisher: Cengage Limited
bartleby

Videos

Expert Solution & Answer
Book Icon
Chapter 7, Problem 6PE

a.

Explanation of Solution

Program:

File name: “Alphabetize.java

//Import necessary header files

import java.util.*;

//Define a class named Alphabetize

public class Alphabetize

{

    //Define main method

    public static void main(String[] args)

    {

        //Declare the variables

        String str1, str2, str3;

        //Create an object for the Scanner class

        Scanner in = new Scanner(System.in);

        //Prompt the user to enter the first string

        System.out.print("Enter first string >> ");

        str1 = in.nextLine();

        //Prompt the user to enter the second string

        System.out.print("Enter second string >> ");

        str2 = in...

b.

Explanation of Solution

Program:

File name: “Alphabetize2.java

//Import necessary header files

import java.util.*;

//Define a class named Alphabetize2

public class Alphabetize2

{

    //Define main method

    public static void main(String[] args)

    {

        //Declare the variables

        String str1, str2, str3;

        //Create an object for the Scanner class

        Scanner in = new Scanner(System.in);

        //Prompt the user to enter the first string

        System.out.print("Enter first string >> ");

        str1 = in.nextLine();

        //Prompt the user to enter the second string

        System.out.print("Enter second string >> ");

        str2 = in.nextLine();

        //Prompt the user to enter the third string

        System.out.print("Enter third string >> ");

        str3 = in.nextLine();

        //Check if the Strings were entered in alphabetical order

        if(str1.toLowerCase().compareTo(str2.toLowerCase()) < 0)

            if(str2.toLowerCase().compareTo(str3.toLowerCase()) < 0)

                //Print the result

System.out.println(str1 + " " + str2 + " " + str3);

            else

            if(str3...

Blurred answer
Students have asked these similar questions
Write an application that determines whether a phrase entered by the user is a palindrome. A palindrome is a phrase that reads the same backward and forward without regarding capitalization, spaces or punctuation. And it will allow the user to enter as many phrases as he likes after each iteration.
Write an application that accepts three Strings from the user and displays them in alphabetical order without regard to case.
Write an application named, Lab14.java. This application will do the following: 1. Display an introductory message 2. Choose a random word from the file, wordlist.txt, and display it 3. Disguise the selected word, and display it 4. Ask the user whether to continue, i.e., whether to repeat steps 2, 3, and 4, or quit the application Once the user chooses to stop the application: 5. Display the total number of vowels hidden 6. Display the total number of consonants hidden 7. Display termination message The user will be asked whether to continue playing and will indicate that another game is to be played by answering ‘y’ or ‘Y’ in response to the question, “Want to play again?” asked by the program after displaying each chosen word and its disguised version. If the user’s response is any character other than ‘y’ or ‘Y’, the totals are displayed and then the application termination message is displayed. See examples below. About randomly choosing a word from the file, wordlist.txt, found on…
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
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
C - File I/O; Author: Tutorials Point (India) Ltd.;https://www.youtube.com/watch?v=cEfuwpbGi1k;License: Standard YouTube License, CC-BY
file handling functions in c | fprintf, fscanf, fread, fwrite |; Author: Education 4u;https://www.youtube.com/watch?v=aqeXS1bJihA;License: Standard Youtube License