当前位置: 代码迷 >> 综合 >> HDOJ 2090 算菜价
  详细解决方案

HDOJ 2090 算菜价

热度:27   发布时间:2023-10-21 18:57:47.0

HDACM 2090

注意:用Scanner类的hasNext()方法来控制循环

import java.util.Scanner;public class Main{public static void main(String[] args) {Scanner sc = new Scanner(System.in);double sum = 0;while (sc.hasNext()) {sc.next();double amount = sc.nextDouble();double price = sc.nextDouble();sum += amount*price;}System.out.printf("%.1f",sum);System.out.println();sc.close();}
}