Last active
January 3, 2016 03:14
-
-
Save susannah-go/819a82350ac737004088 to your computer and use it in GitHub Desktop.
R solution to Day 2: Arithmetic! of HackerRank's 30 Days of Code contest.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
f <- file("stdin") | |
x <- readLines(f) | |
origPrice <- as.numeric(x[1]) | |
tipPercent <- as.numeric(x[2]) | |
taxPercent <- as.numeric(x[3]) | |
tip <- origPrice * tipPercent / 100 | |
tax <- origPrice * taxPercent / 100 | |
finalPrice <- floor(origPrice + tip + tax + 0.5) | |
cat("The final price of the meal is $", finalPrice, ".", sep="") | |
close(f) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment