votako

if\else

Dec 12th, 2012
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.69 KB | None | 0 0
  1. package temperature;
  2. import out.*;
  3.  
  4. public class TemperatureConverter {
  5.     public void convertTemp
  6.             (int temperature, char convertTo){
  7.         if (convertTo=='F'){
  8.             Print.print(temperature+" F");
  9.         }else if (convertTo=='C'){
  10.             Print.print(temperature+" C");
  11.         }else if (convertTo=='K'){
  12.             if (temperature<0){
  13.                 Print.print("no");
  14.             }else {
  15.             Print.print(temperature+" K");}
  16.         }else {
  17.             Print.print("ne FCK");
  18.         }
  19.     }
  20.     public static void main(String[] args){
  21.         TemperatureConverter temp = new TemperatureConverter();
  22.         temp.convertTemp(-1, 'K');
  23.     }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment