View Code of Problem 118

import  java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner scanner=new Scanner(System.in);
		int k=1;
		while(scanner.hasNext()) {
			double dis=scanner.nextDouble();
			double money=0;
			if(dis<=3) {
				money=5.0;
			}
			else {
				money=5+(dis-3)*1.5;
				if(money!=(int) money) {
					money+=1;
				}
			}
			System.out.println("Case #"+(k++)+": "+(int)money);
		}
	}
}

Double click to view unformatted code.


Back to problem 118