Last active
August 29, 2015 14:06
-
-
Save agargiulo/1367f2219bdf3a17c5f7 to your computer and use it in GitHub Desktop.
Floating point fun
This file contains hidden or 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
#!/usr/bin/zsh | |
money=103.4 | |
print "ruby vs python:" | |
diff <(echo $money | ruby ex12b.rb) <(echo $money | python3 ex12b.py) && print "No changes" | |
print "ruby vs java:" | |
diff <(echo $money | ruby ex12b.rb) <(echo $money | java ex12b) && print "No changes" |
This file contains hidden or 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
import java.util.*; | |
class ex12b | |
{ | |
public static void main(String args[]) | |
{ | |
System.out.print("Give me some money: "); | |
Scanner in = new Scanner(System.in); | |
float money = Float.parseFloat(in.next()); | |
float change = money * .1f; | |
System.out.println("Your change is $" + change + "!"); | |
} | |
} |
This file contains hidden or 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
money = input("Give me some money: ") | |
money = float(money.strip()) | |
change = money * .1 | |
print("Your change is $%s!" % change) |
This file contains hidden or 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
print "Give me some money: " | |
money = gets.chomp.to_f | |
change = money * 0.1 | |
puts "Your change is $#{change}!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment