⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 2-3question1.cpp

📁 This is solution code c++ in class lesson.
💻 CPP
字号:
/*
1. Take input hr and min
2. evaluate the parking fee
   - evaluate the free case
         if hr is 0 and min is less than or equal to 10 the fee is 0
   - evaluate not free case
        * if min is more than or equal to 10 increment hr by 1
        * if hr is greater tham 1 fee is 50 + (hr -1) * 30
          else the fee is 50
3. display the parking fee
*/
#include<iostream>
using namespace std;
int main()
{
    int hr, min;
    int tmp;
    double fee;
    cout << "Enter amount of time (hr and min): ";
    cin >> hr >> min;
    tmp = hr; // to preserver the number of hr for output
    if (hr == 0 && min <= 10){
           fee = 0;
    }else{
       if (min >= 10) tmp = tmp + 1;
       if (tmp > 1) fee = 50 + ((tmp - 1) * 30);
       else fee = 50;
    }
    cout << "The parking fee for " << hr << " hour(s) and " << min << " min(s) is " ;
    cout << fee  << " Baht" << endl;
    system("pause");
    return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -