Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class MultiplyBy2 {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- while (true) {
- double number = Double.parseDouble(scanner.nextLine());
- if (number >= 0) {
- System.out.printf("Result: %.2f\n", number * 2);
- } else {
- System.out.println("Negative number!");
- break;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement