Giter VIP home page Giter VIP logo

temperature_converter_ruby's Introduction

Exercise: Temperature Converter

Goal: create a program that can convert a temperature in fahrenheit, Celsius or Kelvin to the other two units.

  • Try the bonus goals if you have extra time!

Setup

  • Fork and clone this repo to your computer. (or just clone)
  • Write your code in temp_converter.rb.
  • Test your code by running the following the terminal...
$ ruby temp_converter.rb

Instructions

Ask the user for two inputs and store them in their own variables...

  1. A starting temperature value
  2. A temperature unit (e.g., f, C, K). Store each of those in a variable.

Define a convert_temp method that takes those two user inputs as arguments.

Inside the method, create a conditional statement that contains a block for each unit of temperature. It will look something like this...

if temp_unit == "f"
  ...
elsif temp_unit == "C"
  ...
else
  ...
end

Each conditional block should convert the starting temperature to its equivalent value in the other two units (e.g., f should be converted to C and K).

Display the starting and converted values in the console.

  • NOTE: You should only be displaying the starting and converted values for the temperature the user selected at the beginning.
# User selected "f" at the start of the program. So the output is...
fahrenheit: ...
to Celsius: ...
to Kelvin: ...

Feel free to turn to your tablemates for help!

Bonus 1

Store the starting and converted temperatures in a hash. When you print those values to the console, do it by accessing the values in the hash.

Bonus 2

Keep the program running until the user decides to quit.

  • HINT: Requires a while loop.
  • When the program starts, the user should be prompted to enter a temperature OR quit the program.
  • After the program displays the starting/converted temperatures, it should return to the initial user prompt.

Original Repo: GA DC

temperature_converter_ruby's People

Contributors

amaseda avatar tylercrosse avatar myztajay avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.