EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
8th Edition
ISBN: 9781305480537
Author: FARRELL
Publisher: CENGAGE LEARNING - CONSIGNMENT
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
The attached text file lists all vehicles entered to the parking lot of a mega shopping centre for one day. Each line of the text file includes a vehicle make, color, plate number and the date of entry to the mall. Based on the content of this text file and the program result in the console, provide a line-by-line description for the below java program.  Please provide line by line explaination for the code below. And I don't understand line 16, so detail that a bit.
IN JAVA PLEASE           The program will read and store thebad words(Kill,killer,assault,etc.) from the file. Then, it will display the following options to the user.• Enter -1 to exit.• 1 - Enter a sentence for profanity check• 2 - Choose a file for profanity checkIf the user chooses the first option, the program will display a text similar to "Enter a text," then he/shewill enter a text. If the user chooses the second option, a file chooser will be prompted to the user forhim/her to select a "text file. “If the user chooses third option, the program will be terminated.If the program finds any bad words, it will replace them with "*** (exactly 3 stars regardless of wordlength") and write it to the console for the first option or overwrite the existing file for the secondoption. Additional Notes:• Use JFileChooser for file reading and BufferedWriter for file writing operations.• Implement custom exceptions to prevent common run-time errors that the user may cause.• You can ignore…
Java Proram ASAP Please improve and adjust the program which is down below with the futher moddifications because it does not pass the test cases in Hypergrade. Please remove /n from the program and for test case 4 after this line: Please re-enter the file name or type QUIT to exit:\n quitENTER there needs to be nothing. Java Proram ASAP Please improve and adjust the program which is down below with the futher moddifications because it does not pass the test cases in Hypergrade. Please remove /n from the program and for test case 4 after this line: Please re-enter the file name or type QUIT to exit:\n quitENTER there needs to be nothing. import java.io.*;import java.util.Scanner;public class ConvertText {    public static void main(String[] args) throws Exception {        Scanner sc = new Scanner(System.in);        System.out.println("Please enter the file name or type QUIT to exit:");        while (true) {            String input = sc.next();            if (input.compareTo("QUIT") ==…
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
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,
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