String.format

Lab Java Beginner 10 points

Read a name, a score (integer) and a percentage (decimal). Build the line NAME scored SCORE points (PCT%) with String.format, the percentage with 1 decimal, and print it in upper case.

Input

Three lines.

Output

One line.

Example

Input

Asha
87
92.456

Output

ASHA SCORED 87 POINTS (92.5%)
Sample input available Sample output available
Editor
Java

Hints

%% prints a literal percent sign in a format string.

Solution explanation

String.format works like printf but returns the text instead of printing it.

Show solution
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String name = sc.nextLine();
        int score = Integer.parseInt(sc.nextLine().trim());
        double pct = Double.parseDouble(sc.nextLine().trim());
        String line = String.format("%s scored %d points (%.1f%%)", name, score, pct);
        System.out.println(line.toUpperCase());
    }
}
Output
Answer
HOME LEARN COMMUNITY DASHBOARD