hkokay
hkokay

Reputation: 57

how to make the whole phrase turn into uppercase and lower case, not just the first word or letter but the entire phrase

i cant seem to make the whole phrase upper case or lower case, only the first word shows and capitalizes

import java.util.Scanner;

public class Main
{
    public static void main(String[] args)
    {
        //declarations
        Scanner keyboard = new Scanner(System.in);

        //input section
        System.out.print("Enter Your First Name: ");
        String first = keyboard.next();
        System.out.print("Enter Your Middle Name: ");
        String middle = keyboard.next();
        System.out.print("Enter Your Last Name: ");
        String last = keyboard.next();
        System.out.print("Enter Your Favorite Phrase: ");
        int stringSize;
        String phrase = keyboard.next();
        String upper = phrase.toUpperCase();
        String lower = phrase.toLowerCase();

        //processing
        String initials = first.substring(0, 1) + middle.substring(0, 1) + last.substring(0, 1);
        System.out.println("Your initials are: " + initials);
        System.out.println("Your phrase in all CAPS: " + upper);
        System.out.println("Your phrase in all lower case: " + lower);
    }
}

the output should read:

Enter your first name: Mark
Enter your middle name: Clay
Enter your last name: Dietrich
Enter your favorite saying: Never give up, never surrender!
Your initials are: MCD
Your phrase in all caps: NEVER GIVE UP, NEVER SURRENDER!
Your phrase in all lowercase: never give up, never surrender!

Upvotes: 0

Views: 79

Answers (1)

mcvkr
mcvkr

Reputation: 3922

import java.util.Scanner;

public class Main
{
    public static void main(String[] args)
    {
        //declarations
        Scanner keyboard = new Scanner(System.in);

        //input section
        System.out.print("Enter Your First Name: ");
        String first = keyboard.nextLine();
        System.out.print("Enter Your Middle Name: ");
        String middle = keyboard.nextLine();
        System.out.print("Enter Your Last Name: ");
        String last = keyboard.nextLine();
        System.out.print("Enter Your Favorite Phrase: ");
        //int stringSize; // dont think you need this
        String phrase = keyboard.nextLine();
        String upper = phrase.toUpperCase();
        String lower = phrase.toLowerCase();

        //processing
        String initials = first.substring(0, 1) + middle.substring(0, 1) + last.substring(0, 1);
        System.out.println("Your initials are: " + initials);
        System.out.println("Your phrase in all CAPS: " + upper);
        System.out.println("Your phrase in all lower case: " + lower);
    }
}

Upvotes: 1

Related Questions