Conversions

From Progteam

Revision as of 02:11, 22 February 2008 by Mlc413 (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search


Conversions
Problem Number B
Sorter: Uncategorized
Source: GNYR ICPC 2007
Link: "http://www.acmgnyr.org/year2007/b.pdf"




Checkmark.jpg This problem has been solved by Mfv2.


This is problem B from the GNYR ICPC 2007






import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int lim = sc.nextInt();
		int i = 1;
		while (lim-- > 0) {
			double amt = sc.nextDouble();
			String u = sc.next();
			if (u.equals("kg")) {
				System.out.printf("%d %.4f lb\n", i++, amt * 2.2046);
			} else if (u.equals("lb")) {
				System.out.printf("%d %.4f kg\n", i++, amt * .4536);
			} else if (u.equals("l")) {
				System.out.printf("%d %.4f g\n", i++, amt * .2642);
			} else if (u.equals("g")) {
				System.out.printf("%d %.4f l\n", i++, amt * 3.7854);
			}
		}	 
	}
}



Personal tools