2017년 11월 20일 월요일

[C++] HackerRank Day2 Solution

/*
https://www.hackerrank.com/challenges/30-operators/problem


*/


#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;


int main() {

    double price,tip_rate ,tax_rate,tip,tax,totalCost;
 
    cin >> price;
    cin >> tip_rate;
    cin >> tax_rate;
 
    tip = price * tip_rate / 100;
    tax = price * tax_rate / 100;
 
    totalCost = price + tip + tax + 0.5;   // add 0.5 to round the value
 
    cout << "The total meal cost is " << (int)totalCost << " dollars." << endl;;
 
 
    return 0;
}

댓글 없음:

댓글 쓰기