Char Learn programming Java

Lesson:

Basic Data Types


Exercise:

Char 12


Objetive:

Write a java program to ask the user for three letters and display them in reverse order.


Code:

import java.util.*;
public class Main
{
	public static void main(String[] args)
	{
		char letter, letter2, letter3;

		System.out.print("Enter letter: ");
		letter = (char)new Scanner(System.in).nextLine();

		System.out.print("Enter letter: ");
		letter2 = (char)new Scanner(System.in).nextLine();

		System.out.print("Enter letter: ");
		letter3 = (char)new Scanner(System.in).nextLine();

		System.out.printf("%1$s %2$s %3$s" + "\r\n", letter3, letter2, letter);
	}
}