ITST Basic 题目4 停车费计算 (Java)

题目:停车费计算
说明:计算出停车时间后,依据题目设定算出最后需支付的停车费用

import java.util.Scanner;public class Main {public static void main(String[] args) {Scanner sc = new Scanner(System.in);int min1 = sc.nextInt();int s1 = sc.nextInt();int min2 = sc.nextInt();int s2 = sc.nextInt();int time1 = min1 * 60 + s1;int time2 = min2 * 60 + s2;int result = 0;int time = time2 - time1;if(time < 120 && time > 0) {result = (time) / 30 * 30; }else if(time <= 240 && time >= 120){result = (time-120) / 30 * 40 + 120; }else{result = (time-240) / 30 * 60 +120 +160; }System.out.println(result);}}

关于作者: 网站小编

码农网专注IT技术教程资源分享平台,学习资源下载网站,58码农网包含计算机技术、网站程序源码下载、编程技术论坛、互联网资源下载等产品服务,提供原创、优质、完整内容的专业码农交流分享平台。

热门文章