SHARE
SPREAD
HELP

The Tradition of Sharing

Help your friends and juniors by posting answers to the questions that you know. Also post questions that are not available.


To start with, Sr2Jr’s first step is to reduce the expenses related to education. To achieve this goal Sr2Jr organized the textbook’s question and answers. Sr2Jr is community based and need your support to fill the question and answers. The question and answers posted will be available free of cost to all.

 

#
Authors:
Walter Savitch ,kenrick Mock
Chapter:
Console Input And Output
Exercise:
Programming Projects
Question:8 | ISBN:9780132830317 | Edition: 5

Question

Write a program that reads in a line of text and then outputs that line of text first in all uppercase letters and then in all lowercase letters.


TextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbook

Answer

import java.util.Scanner;

public class LettersDemo {
	public static void main(String[] args)
	{

		Scanner input = new Scanner(System.in);
		String textLine;
		System.out.print("Enter a line of text:");
		textLine = input.nextLine();
		System.out.println("Text in uppercase:"+textLine.toUpperCase());
		System.out.println("Text in lowercase:"+textLine.toLowerCase());
	}
}

OUTPUT:

Enter a line of text:Hello How Are You
Text in uppercase:HELLO HOW ARE YOU
Text in lowercase:hello how are you

 

0 0

Discussions

Post the discussion to improve the above solution.