Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Main {
- public static void main(String[] args) {
- Conv cf = new Conv();
- cf.convTemp('F');
- }
- }
- public class Conv {
- float temp = 36;
- char convTo;
- public void convTemp(char convTo) {
- if (convTo == 'F') {
- System.out.println("Current temperature is " + temp + "C");
- temp = (temp - 32) * (5 / 9);
- System.out.println("That equals to " + temp + "F");
- } else if (convTo == 'C') {
- System.out.println("Current temperature is " + temp + "F");
- temp = (temp + 32) * (9 / 5);
- System.out.println("Temperature equals to " + temp + "C");
- } else {
- System.out.println("Undefined value");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement