코딩로그
[백준/BOJ/C++] 6763번 Speed fines are not fine! 본문
[문제]
Many communities now have “radar” signs that tell drivers what their speed is, in the hope that they will slow down.
You will output a message for a “radar” sign. The message will display information to a driver based on his/her speed according to the following table:
km/h over the limit | Fine |
1 to 20 | $100 |
21 to 30 | $270 |
31 or above | $500 |
[입력]
The input will be two integers. The first line of input will be speed limit. The second line of input will be the recorded speed of the car.
[출력]
If the driver is not speeding, the output should be:
Congratulations, you are within the speed limit!
If the driver is speeding, the output should be:
You are speeding and your fine is $F.
where F is the amount of the fine as described in the table above.
[Source Code]
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
int limit, speed;
cin >> limit >> speed;
int line = speed - limit;
if(line < 1)
cout <<"Congratulations, you are within the speed limit!";
else if(line < 21)
cout << "You are speeding and your fine is $100.";
else if(line < 31)
cout << "You are speeding and your fine is $270.";
else
cout << "You are speeding and your fine is $500.";
}
[결과 화면]
'YJ > C++' 카테고리의 다른 글
[백준/BOJ/C++] 4613번 Quicksum (0) | 2021.11.09 |
---|---|
[백준/BOJ/C++] 4597번 패리티 (0) | 2021.11.09 |
[백준/BOJ/C++] 16503번 괄호 없는 사칙연산 (0) | 2021.11.08 |
[백준/BOJ/C++] 11367번 Report Card Time (0) | 2021.11.08 |
[백준/BOJ/C++] 11549번 Identifying Tea (0) | 2021.11.08 |