013-001-003
String Handling Class: Message Formatting
Medium
Problem Description
String Handling class: Message Formatting
In this problem, you will create a program that uses String class methods (toUpperCase(), length(), substring()) to convert a string to uppercase, get its length, and extract the first 3 characters, then displays each result to standard output.
Learning Objective: Understand basic String class operations
Create a program that inputs a string and displays uppercase, length, and substring.
Input
Line 1: String
Output
Original: [original string]
Upper: [uppercase]
Length: [length]
First 3: [first 3 characters]
Example
Input:
hello
Output:
Original: hello
Upper: HELLO
Length: 5
First 3: hel
Test Cases
※ Output examples follow programming industry standards
Input:
hello
Expected Output:
Original: hello Upper: HELLO Length: 5 First 3: hel
Input:
world
Expected Output:
Original: world Upper: WORLD Length: 5 First 3: wor
Input:
Java
Expected Output:
Original: Java Upper: JAVA Length: 4 First 3: Jav
Input:
Python
Expected Output:
Original: Python Upper: PYTHON Length: 6 First 3: Pyt
❌ Some tests failed
Your Solution
Current Mode:● My Code
99
1
2
3
4
5
6
7
8
9
10
›
⌄
⌄
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
// Write your code here
sc.close();
}
}
0 B / 5 MB
You have 7 free executions remaining
