Temperature - Mithali Shenoy [email protected] This program...

This preview shows page 1 - 2 out of 4 pages.

/* * Mithali Shenoy * [email protected] * This program is a blueprint class that performs several operations through its methods in regard to the temperatures * given in the client code. */ public class Temperature { private double value; private char scale; public void setScale (char scale){ if (scale!= 'F' && scale!= 'C'&& scale != 'K'){ throw new IllegalArgumentException(); } this.scale = scale; } public void setValue (double value){ if (this.scale == 'F' ){ if (this.value < -459.67){ throw new IllegalArgumentException(); } }else if (this.scale=='C'){ if (this.value < -273.15){ throw new IllegalArgumentException(); } }else if (this.scale =='K'){ if (this.value < 0.0){ throw new IllegalArgumentException(); } } this.value = value; } public void changeTo (double value, char scale){ if (scale!= 'F' && scale!= 'C'&& scale != 'K'){ throw new IllegalArgumentException(); } if (scale == 'F' ){ if (value < -459.67){ throw new IllegalArgumentException(); } }else if (scale=='C'){ if (value < -273.15){ throw new IllegalArgumentException(); } }else if (scale =='K'){ if (value < 0.0){ throw new IllegalArgumentException(); } } this.setValue (value); this.setScale (scale); } public double getValue(){ return this.value; }
Image of page 1

Want to read all 4 pages?

Image of page 2

Want to read all 4 pages?

You've reached the end of your free preview.

Want to read all 4 pages?

  • Spring '13
  • DaveSullivan

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern