Mindtap Computing, 1 Term (6 Months) Printed Access Card For Farrell’s Java Programming, 8th
Mindtap Computing, 1 Term (6 Months) Printed Access Card For Farrell’s Java Programming, 8th
8th Edition
ISBN: 9781337091480
Author: Joyce Farrell
Publisher: Cengage Learning
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.
Create an application that accepts a sentence as input and converts each word to “Pig Latin.” In one version, to convert a word to Pig Latin you remove the first let- ter and place that letter at the end of the word. Then you append the string "ay" to the word. Here is an example: English: I SLEPT MOST OF THE NIGHT Pig Latin: IAY LEPTSAY OSTMAY FOAY HETAY IGHTNAY
2. Write a program with a user interface which allows the user to enter 2 integers. It should then give him the option of adding them, subtracting them, multiplying them or dividing them. It should then print the result. 3. Write a program with a user interface to allow a user to enter a number and to tell him whether the number is even or odd Use the truncating property of int
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
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
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