1011

来源:互联网 发布:交换机有mac地址吗 编辑:程序博客网 时间:2024/05/26 09:57

题意:

水!!!

分析

本来是水题一道,以为半个小时就能解决,可是,万万没想到啊,最后搞得泪流满面啊!!!

double a = 7.5;double b = 4.1;duoble p = a*b;

p得等于30.75吧

可是,竟然等于30.7499999999999!!!

欲哭无泪啊!!!

破double!!!

package AdvancedLevelPractice;import java.util.Scanner;public class pat1011 {public static void main(String[] args) {// TODO Auto-generated method stubScanner scanner = new Scanner(System.in);float bet1,bet2,sum = 1;int index;char ch = ' ';for(int i = 0; i < 3; i++){index = 0;bet1 = scanner.nextFloat();for(int j = 1; j < 3; j++ ){bet2 = scanner.nextFloat();if(bet2 > bet1){bet1 = bet2;index = j;}}switch(index){case 0:ch = 'W';break;case 1:ch = 'T';break;case 2:ch = 'L';break;}System.out.print(ch+" ");sum *= bet1;}double profit = (sum * 0.65 - 1) * 2;System.out.print(String.format("%.2f", profit));scanner.close();}}


0 0