**Input Format**

There are lines of numeric input:

The first line has a double, (the cost of the meal before tax and tip).

The second line has an integer, (the percentage of being added as tip).

The third line has an integer, (the percentage of being added as tax).

The first line has a double, (the cost of the meal before tax and tip).

The second line has an integer, (the percentage of being added as tip).

The third line has an integer, (the percentage of being added as tax).

**Output Format**

Print the total meal cost, where is the rounded integer result of the entire bill ( with added tax and tip).

###
__Problem solution in a c programming language__

#include <stdio.h> #include <math.h> int main() { double mealCost; int tipPercent; int taxPercent; scanf("%lf", &mealCost); scanf("%d", &tipPercent); scanf("%d", &taxPercent); double tip = mealCost * tipPercent / 100; double tax = mealCost * taxPercent / 100; int totalCost = (int) round(mealCost + tip + tax); printf("The total meal cost is %d dollars.", totalCost); return 0; }

###
__Problem solution in c++ programming language__

#include <cmath> #include <iostream> using namespace std; int main() { int tipPercent; int taxPercent; double mealCost; scanf("%lf %d %d", &mealCost, &tipPercent, &taxPercent); // OR: cin >> mealCost >> tipPercent >> taxPercent; double tip = mealCost * tipPercent / 100; double tax = mealCost * taxPercent / 100; int totalCost = round(mealCost + tip + tax); printf("The total meal cost is %d dollars.", totalCost); return 0; }

###
__Problem solution in Java programming language.__

import java.util.*; public class Arithmetic { public static void main(String[] args) { Scanner scan = new Scanner(System.in); double mealCost = scan.nextDouble(); // original meal price int tipPercent = scan.nextInt(); // tip percentage int taxPercent = scan.nextInt(); // tax percentage scan.close(); // Calculate Tax and Tip: double tip = mealCost * tipPercent / 100; double tax = mealCost * taxPercent / 100; // cast the result of the rounding operation to an int and save it as totalCost int totalCost = (int) Math.round(mealCost + tax + tip); System.out.println("The total meal cost is " + totalCost + " dollars."); } }

###
__Problem solution in Javascript programming language__

'use strict'; var _input = ''; var _index = 0; process.stdin.on('data', (data) => { _input += data; }); process.stdin.on('end', () => { _input = _input.split(new RegExp('[\n ]+')); main(+(_input[0]), +(_input[1]), +(_input[2])); }); function main(mealCost, tipPercent, taxPercent) { let tip = mealCost * tipPercent / 100; let tax = mealCost * taxPercent / 100; let totalCost = Math.round(mealCost + tax + tip); console.log("The total meal cost is " + totalCost + " dollars."); }

###
__Problem solution in Python 2 programming language__

def get_total_cost_of_meal(): # original meal price meal_cost = float(raw_input()) # tip percentage tip_percent = int(raw_input()) # tax percentage tax_percent = int(raw_input()) # Write your calculation code here tip = meal_cost * tip_percent / 100 tax = meal_cost * tax_percent / 100 # cast the result of the rounding operation to an int and save it as total_cost total_cost = int(round(meal_cost + tip + tax)) return str(total_cost) # Print your result print("The total meal cost is " + get_total_cost_of_meal() + " dollars.")

###
__Problem solution in Python 3 programming language.__

def get_total_cost_of_meal(): # original meal price meal_cost = float(input()) # tip percentage tip_percent = int(input()) # tax percentage tax_percent = int(input()) # Write your calculation code here tip = meal_cost * tip_percent / 100 tax = meal_cost * tax_percent / 100 # cast the result of the rounding operation to an int and save it as total_cost total_cost = int(round(meal_cost + tax + tip)) return str(total_cost) # Print your result print("The total meal cost is " + get_total_cost_of_meal() + " dollars.")

###
__Problem solution in Ruby programming language__

def get_total_cost_of_meal() # original meal price meal_cost = gets.to_f # tip percentage tip_percent = gets.to_i # tax percentage tax_percent = gets.to_i # Write your calculation code here tip = meal_cost * tip_percent / 100 tax = meal_cost * tax_percent / 100 # cast the result of the rounding operation to an int and save it as total_cost total_cost = (meal_cost + tax + tip).round.to_i return total_cost end # Print your result print("The total meal cost is ", get_total_cost_of_meal(), " dollars.")

###
__Problem solution in the Swift programming language.__

import Foundation let mealCost = Double(readLine()!)!; // original meal price let tipPercent = Double(readLine()!)!; // tip percentage let taxPercent = Double(readLine()!)!; // tax percentage // Calculate Tax and Tip doubles: let tip = mealCost * tipPercent / 100; let tax = mealCost * taxPercent / 100; // cast the result of the rounding operation to an int and save it as totalCost let totalCost = Int(round(mealCost + tax + tip)); print("The total meal cost is \(totalCost) dollars.");

## 0 Comments