- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
编写一个程序,在给出以下信息时计算将车停在 parking 场的顾客的 parking 费:
a.显示车辆类型的字符:C 代表轿车,B 代表巴士,T 代表卡车
b. 0 到 24 之间的整数,显示车辆进入 parking 场的时间。
c. 0 到 60 之间的整数,显示车辆进入 parking 场的分钟。
d. 0 到 24 之间的整数,显示车辆离开 parking 场的时间。
e. 0 到 60 之间的整数,显示车辆离开 parking 场的分钟数。
由于这是一个公共(public) parking 场,因此鼓励人们只 parking 很短一段时间。管理层对每种类型的车辆采用两种不同的费率。
当晚午夜,任何车辆不得在 parking 场停留;它将被拖走。 parking 费还需缴纳 6% 的消费税。
g。编写一个程序i.显示介绍信息二.提示用户输入相关信息。三.使用以下格式显示帐单。
h。您的计划将包括以下标准。我。验证入时和超时。二.使用 switch 语句来区分不同类型的车辆。三.使用适当的循环语句以允许重复计算 parking 费四.使用表 1 使用适当的测试数据运行程序五次
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
char type; //Variable for vehicle types
int hourIn, minuteIn, hourOut, minuteOut, entry, exit, totalParkingTime; //Variable for time
float totalRounded, totalChargeFee, GST; //Variable for fare
printf("Welcome to Help Parking Lot!\n"); //Introduction message
printf("Enter type of vehicle: %c", type); //Type of vehicles: C for car, T for truck, B for bus
scanf("%c", &type);
switch(type)
{
case 'C':
if(totalParkingTime <= 3)
totalChargeFee = 0.8 * totalParkingTime;
else
totalChargeFee = 0.8 * 3 + 1.5 * (totalParkingTime - 3);
break;
case 'T':
if(totalParkingTime <= 2)
totalChargeFee = 1.5 * totalParkingTime;
else
totalChargeFee = 1.5 * 2 + 2.3 * (totalParkingTime - 2);
break;
case 'B':
if(totalParkingTime <= 1)
totalChargeFee = 2 * totalParkingTime;
else
totalChargeFee = 2 * 1 + 3.4 * (totalParkingTime - 1);
break;
}
scanf("%f", &totalChargeFee);
printf("Enter an integer between 0 and 24 showing the hour the vehicle entered the lot: %d", hourIn); //The hour of veicle enter in military format
scanf("%d", &hourIn);
printf("Enter an integer between 0 and 60 showing the minute the vehicle entered the lot: %d", minuteIn); //The minute of vehicle enter in military format
scanf("%d", &minuteIn);
printf("Enter an integer between 0 and 24 showing the hour the vehicle exited the lot: %d", hourOut); //The hour of vehicle exit in military format
scanf("%d", &hourOut);
printf("Enter an integer between 0 and 60 showing the minute the vehicle exited the lot: %d", minuteOut); //The minute of vehicle exit in military format
scanf("%d", &minuteOut);
entry = hourIn + minuteIn;
scanf("%d", &entry);
exit = hourOut + minuteOut;
scanf("%d", &exit);
totalParkingTime = exit - entry;
//User's bill is shown here
printf("HELP PARKING LOT CHARGE\n Type of vehicle: %c\n TIME-IN\n \t\t\t %d:%d\n TIME-OUT\n \t\t\t %d:%d\n \t\t\t------\n PARKING TIME %d:%d\n ROUNDED TOTAL \t\t\t%f\n \t\t\t------\n TOTAL CHARGE \t\t RM%.2f\n GST \t\t\t RM%.2f\n TOTAL \t\t\t RM%.2f");
return 0;
}
我不知道如何让它计算时间和超时的小时和分钟差异以及车辆的类型。当我运行程序时,时间输入有错误。但显示格式是正确的。
最佳答案
你意识到这里了吗:
if(type == 'C' && totalHourParked <= 3)
{
totalChargeFee = 0.8 * totalHourParked;
}
else
{
totalChargeFee = 1.5 * totalHourParked;
}
所有B&T类型都会进入else语句吗?
在尝试编码之前,我鼓励您拿起纸和笔并尝试编写某种伪代码。之后,尝试手动测试。如果您对此有信心,请对其进行编码。测试一下。如果这些都不起作用,那么请将你的问题暴露给 stackoverflow。
关于c - parking 收费计划,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42548488/
当我创建订阅时,我设置了一些元数据来识别我在数据库中的订单。当我收到 webhook charge.succeeded 时,来自订阅的元数据未在此事件中传递,我无法识别与此付款相关的订单。如何在与订阅
我正在使用 PayPal Vault 服务将金额从存储的信用卡转移到 PayPal 专业账户。 这是我遵循的文档链接:https://developer.paypal.com/docs/integra
我想将 CloudKit 用于我的一个免费的新应用程序 (0 美元)。这就是为什么如果我的应用程序达到 Apples Cloud Kit 计划的免费套餐限制并产生费用会很糟糕。 我阅读了一些帖子、官方
我在我的应用程序中使用 Azure 推送通知。为了创建移动服务,它需要在其中创建 SQL 数据库,对于 SQL 数据库,我的费用约为 3.5 美元/月。但是当我打开该数据库时,里面什么也没有。问题是为
我通过 Google 的应用内结算购买了受管理产品的应用内购买。 订单正在处理中,但我在 Wallet Merchant Center 中看到订单状态为 Chargeable。 奇怪的是,订单状态是
使用基本版本的 EC2 实例时,“流量”是否有任何变化,基本的意思是: 每月 750 小时的 Linux、RHEL 或 SLES t2.micro 实例使用时间 流量:如果我们设置了一个服务器,并且我
使用基本版本的 EC2 实例时,“流量”是否有任何变化,基本的意思是: 每月 750 小时的 Linux、RHEL 或 SLES t2.micro 实例使用时间 流量:如果我们设置了一个服务器,并且我
我正在使用Angular-Stripe-Checkout library创建像这样的 stripeToken example 。一些亮点如下所示。 与许多 Angular-stripe 库和示例一样,
我将卡信息存储在数据库中,例如客户首次付款时的卡 ID card_***** 和客户 ID cus_**** 以供以后使用.用户选择他的卡,例如以单选按钮 visa****4242 的形式,并使用卡
例如: count = 0 while True: try: if count == 5:
表单已提交两次:1. 页面加载2. 当用户点击结帐按钮时 我想避免第一次提交,它会抛出错误,因为返回的 token 为空:com.stripe.exception.InvalidRequestExce
我正在尝试通过自定义按钮使用 Stripe 的新结帐功能,通过 AJAX POST 将 token 发送到 php 文件,然后该文件将执行收费。不幸的是,我在从 POST 变量中检索 token 时遇
我是一名优秀的程序员,十分优秀!