-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit a43248a
Showing
1 changed file
with
47 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
class Gradus | ||
def input() | ||
puts "Enter gradus" | ||
@n = gets.chomp.to_i | ||
puts "Enter now scale" | ||
@a = gets.chomp | ||
puts "Enter new scale" | ||
@b = gets.chomp | ||
puts "Now #{@n} #{@a}" | ||
end | ||
|
||
def convert() | ||
case @a | ||
when "C" | ||
case @b | ||
when "K" | ||
@n = @n + 273.15 | ||
when "F" | ||
@n = @n * 1.8 + 32 | ||
end | ||
when "K" | ||
case @b | ||
when "C" | ||
@n = @n - 273.15 | ||
when "F" | ||
@n = @n * 1.8 - 459.67 | ||
end | ||
when "F" | ||
case @b | ||
when "C" | ||
@n = (@n - 32) / 1.8 | ||
when "K" | ||
@n = (@n + 459.67) / 1.8 | ||
end | ||
end | ||
end | ||
|
||
def output() | ||
puts "New #{@n} #{@b}" | ||
end | ||
end | ||
|
||
gr = Gradus.new | ||
gr.input | ||
gr.convert | ||
gr.output | ||
|