Skip to content

Instantly share code, notes, and snippets.

@susannah-go
Last active January 3, 2016 03:14
Show Gist options
  • Save susannah-go/819a82350ac737004088 to your computer and use it in GitHub Desktop.
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.
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