Temprature conv

download Temprature conv

of 10

Transcript of Temprature conv

  • 7/27/2019 Temprature conv

    1/10

    INTRODUCTION

    TEMPERATERE CONVERTER

    Change the temperature from one form to other.

    Celcius Fahrenheit Reaumur

    This program provide a different form of temperature

    - Celcius: it is SI unit of temperature.

    - Fahrenheit: On the Fahrenheit scale, the freezing point of water is 32 degrees Fahrenheit (F) and

    the boiling point 212 F (at standard atmospheric pressure). This puts the boiling and freezing points of

    water exactly 180 degrees apart.

    - Reaumur:The Raumur scale (R, Re, R), also known as the "octogesimal division" isa temperature scale in which the freezing and boiling points of water are set to 0 and 80 degrees respec-

    tively. The scale is named after Ren Antoine Ferchault de Raumur who first proposed something simi-

    lar in 1730.

    ABOUT JAVA

    Java technology is both a programming language and a platform.

    The Java Programming Language

    The Java programming language is a high-level language that can be characterized by all of the

    following buzzwords:

    Compiled and Interpreted

    Platform independent & Portable

    Object-Oriented

    Robust & Secure

    Distributed

    Simple , Small & Familiar

    Multithreaded & Interactive

    High Performance

    Dynamic & Extensible

    The Java Environment

  • 7/27/2019 Temprature conv

    2/10

    Program Organization Standards

    Each class is implemented in its own source file.

    Include one class per file:Name of the Java file is the same as the class name.

    Java applications must include a class with a

    main method.E.g.,

    public static void main(String args[])Unlike C++ a logic expression does not evaluate to 0 (FALSE) and non-0 (TRUE), it evaluates

    to eithertrue orfalse

    true, false are values of the boolean data Type.

    Java Exception Handling

    An exception is an object that defines an unusual or erroneous situation.

    An exception is thrownby a program or a runtime environment and can be caughtand handled

    appropriately.

    Java supports user-defined and predefined exceptions:

    ArithmeticException ArrayIndexOutOfBoundsE xception

  • 7/27/2019 Temprature conv

    3/10

    FileNotFoundException

    InstantiationException

    Exception handling allows a programmer to divide a program into a normal executionflow and

    an exception execution flow.

    If an exception is not handled the program will terminate (abnormally) and produce a message.

    public class DivideBy0

    {public static void main (String[] args) {

    System.out.println(10/0);

    }}

    Java.lang.ArithmeticException: / by zero

    at DivdeBy0.main(DivdeBy0:3)

    try {

    statement-list1} catch (exception-class1 variable1) {

    statement-list2} catch (exception-class2 variable2) {

    statement-list3

    } catch

    The Java Platform

    Aplatform is the hardware or software environment in which a program runs. We've alreadymentioned some of the most popular platforms like Microsoft Windows, Linux, Solaris OS, and

    Mac OS. Most platforms can be described as a combination of the operating system and underly-

    ing hardware. The Java platform differs from most other platforms in that it's a software-only

    platform that runs on top of other hardware-based platforms.The Java platform has two components:

    TheJava Virtual Machine TheJava Application Programming Interface (API)

    The general-purpose, high-level Java programming language is a powerful software platform.Every full implementation of the Java platform gives you the following features:

    Development Tools: The development tools provide everything you'll need for compiling, run-

    ning, monitoring, debugging, and documenting your applications.

    Application Programming Interface (API): The API provides the core functionality of the Ja-va programming language. It offers a wide array of useful classes ready for use in your own ap-

    plications. It spans everything from basic objects, to networking and security, to XML generation

    and database access, and more.

  • 7/27/2019 Temprature conv

    4/10

    Deployment Technologies: The JDK software provides standard mechanisms such as the Java

    Web Start software and Java Plug-In software for deploying your applications to end users.

    Program Organization

    In the Java programming language, all source code is first written in plain text files ending with

    the .java extension. Those source files are then compiled into .class files by the javac compiler. A.class file does not contain code that is native to your processor; it instead contains bytecodes

    the machine language of the Java Virtual Machine1 (Java VM). The java launcher tool then runs

    your application with an instance of the Java Virtual Machine.

    Swing

    The Java Swing provides the multiple platform independent APIs interfaces for interacting be-tween the users and GUIs components. All Java Swing classes imports form the import ja-

    vax.swing.*; package. Java provides an interactive features for design the GUIs toolkit or com-

    ponents like: labels, buttons, text boxes, checkboxes, combo boxes, panels and sliders etc. All

    AWT flexible components can be handled by the Java Swing. The Java Swing supports the plug-ging between the look and feel features. The look and feel that means the dramatically changing

    in the component like JFrame, JWindow, JDialog etc. for viewing it into the several types of

    window.

    1. JOptionPane Basics

    Static methods in the JOptionPane class let you easily create modal dialogs to show messages

    (JOptionPane.showMessageDialog), to ask for confirmation (JOptionPane.showConfirmDialog),to let the user enter text or to choose among predefined options (JOptionPane.showInputDialog),

    or to choose among a variety of buttons (JOptionPane.showOptionDialog). Each of these meth-

    ods either returns an int specifying which button was pressed, or a String specifying the option

    selected.

  • 7/27/2019 Temprature conv

    5/10

    HARDWARE AND SOFTWARE REQUIREMENT

    Software Requirements

    1: Operating System : Window 72: Front End : jdk1.7.0_21

    Hardware Requirements

    1: Machine : intel i3 core

    2: Speed : 2.40 GHz

    3: Hard Disk : 320 GB

    4: RAM : 3GB

    OUTPUT LAYOUT

  • 7/27/2019 Temprature conv

    6/10

    SOURCE CODE

    import javax.swing.JOptionPane;

    public class TempratureConvertorNew{

    public static void main(String args[]){

    try{

    int ch3=0;do

    {String option1=

    JOptionPane.showInputDialog("Your Choice: \n1. Celcius\n2. Fahrenheit");

    int choice1=Integer.parseInt(option1);switch(choice1)

    {case 1:

    int ch1=0;

    do{String secondNumber=

    JOptionPane.showInputDialog("Enter The Temprature","In Celcius");

    double Tc1=Double.parseDouble(secondNumber);

    String option2=JOptionPane.showInputDialog("Your Choice: \n1. Fahrenheit 2. Kel-

    vin\n"+

    "3. Raumur ");int choice11=Integer.parseInt(option2);if(choice11

  • 7/27/2019 Temprature conv

    7/10

    double Tf1=((1.8*Tc1)+32.0);

    JOptionPane.showMessageDialog(null,"The Temprature In Fahr-

    enheit =\n"+Tf1+" F",

    "Temprature In Fahrenheit",JOptionPane.PLAIN_MESSAGE);break;

    case 2:double Tk1=( Tc1 + 273.15 );

    JOptionPane.showMessageDialog(null,"The Temprature In Kelvin

    =\n"+Tk1+" K",

    "Temprature In Kelvin",JOptionPane.PLAIN_MESSAGE);break;

    case 3:

    double Tr1=(.8* Tc1);

    JOptionPane.showMessageDialog(null,"The Temprature In Rau-

    mur =\n"+Tr1+" Re",

    "Temprature In Raumur",JOptionPane.PLAIN_MESSAGE);break;

    }

    }else

    {

    JOptionPane.showMessageDialog(null,"You Have Entered WrongChoice",

    "Error_Message",JOptionPane.ERROR_MESSAGE);}

    String ch11=

    JOptionPane.showInputDialog("Press 1.To continue\n"+

    " 2. To exit");ch1=Integer.parseInt(ch11);

    }while(ch1==1);break;

    case 2:int ch2=0;

    do{

  • 7/27/2019 Temprature conv

    8/10

    String thirdNumber=

    JOptionPane.showInputDialog("Enter The Temprature","In Fahren-hiet");

    double Tf2=Double.parseDouble(thirdNumber);

    String option2=JOptionPane.showInputDialog("Your Choice: \n1. Celcius 2. Kel-

    vin\n"+"3. Raumur ");

    int choice12=Integer.parseInt(option2);

    if(choice12

  • 7/27/2019 Temprature conv

    9/10

    JOptionPane.showMessageDialog(null,"You Have Entered Wrong

    Choice","Error_Message",JOptionPane.ERROR_MESSAGE);

    }

    String ch12=JOptionPane.showInputDialog("Press 1.To continue\n"+

    " 2. To exit");ch2=Integer.parseInt(ch12);

    }while(ch2==1);

    break;

    }String ch13=

    JOptionPane.showInputDialog("Press 1.To continue\n"+

    " 2. To exit");ch3=Integer.parseInt(ch13);}while(ch3==1);

    JOptionPane.showMessageDialog(null,"You Will Exit From Program",

    "Error_Message",JOptionPane.WARNING_MESSAGE);}

    catch(Exception exception)

    {JOptionPane.showMessageDialog(null,"Exception Ocurred....\n You Haven't

    Entered Any value\n Exiting",

    "Exception",JOptionPane.ERROR_MESSAGE);}

    }}

  • 7/27/2019 Temprature conv

    10/10

    OUTPUT