View Code of Problem 96

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while(scanner.hasNext()){
            String input = scanner.nextLine();
            if (input.charAt(0) == '0')break;
            if (input.contains("TB")){
                long n = Integer.valueOf(input.substring(0,input.indexOf("TB")));
                long temp = n * 1024 * 1024 * 1024 * 1024-n * 1000 * 1000 * 1000 * 1000;
                System.out.println(temp);
            }else if (input.contains("GB")){
                long n = Integer.valueOf(input.substring(0,input.indexOf("GB")));
                long temp = n * 1024 * 1024 * 1024-n * 1000 * 1000 * 1000;
                System.out.println(temp);
            }else if (input.contains("MB")){
                long n = Integer.valueOf(input.substring(0,input.indexOf("MB")));
                long temp = n * 1024 * 1024-n * 1000 * 1000;
                System.out.println(temp);
            }else if (input.contains("KB")){
                long n = Integer.valueOf(input.substring(0,input.indexOf("KB")));
                long temp = n * 1024-n * 1000;
                System.out.println(temp);
            }else{
                System.out.println(0);
            }
        }
    }
}

Double click to view unformatted code.


Back to problem 96