Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

public class Main {

    public static int calcLength(String s) {
        double len = 0;
        for (int i = 0; i < s.length(); i++) {
            int temp = (int) s.charAt(i);
            if (temp > 0 && temp < 127) {
                len += 0.5;
            } else {
                len++;
            }
        }
        return (int) len;
    }
}