- Possible Infiltraitors -
Friday, October 1, 2010
Java - my first coding tutorial
// Author-dijidog-2010- (tutorial) a celsius to fahrenheit converter // calculation desired - degreesFahrenheit= 9 / 5 * degreesCelsius + 32   or ()- 32)*5/9;        import java.util.Scanner;/*import declaration-imports the object that is named scanner-it is an object already present in         java scripting language-a pre made scanner that searches and returns one item (token) at a time*/         public class CelsiusToFahrenheit//makes the class visible to all classes using the modifier "public".       {public static void main(String[] args) {// more study needed on this line-these {} separate blocks of code         System.out.println("Celsius to Fahrenheit Converter");         System.out.println("Enter a temperature in CELSIUS: ");//prints lines on screen (this prints out every time program is run)         Scanner Celsius = new Scanner(System.in);/**allows input by the user and creates a variable (token),in this case named Celsius         **and is searched and found by the object "scanner" when the variable Celsius is "called" **/        double Faren = 0.0;//part of the calculation-makes the variable Faren equal 0.0 before converting to double value         //makes the final output a double digit integer - Faren is equal to Celsius if it has nextdouble        if(Faren <10)>110 input create a print line output...wrong placement/altered text to fit the situation.        if(Celsius.hasNextDouble())// if Celsius has a double integer ,two digits, then this( the following line) is true         {Faren = (Celsius.nextDouble()* 9/5) + 32;}//then 0 = Celsius with two digits * 9/5) + 32;)         /**the actual calculation that is computed using the input value received by the variable Celsius.         The input value of Celsius is the number the user enters when prompted)**/         {if(Faren <32)>110) {System.out.println("Ouch...that's very hot!!");}         //prints lines if the Faren is less than 32 and more than 110-works properly, could probably be coded within the above line in a tighter format.         System.out.println("The approximate temperature conversion is ");         System.out.println(Faren + " degrees FARENHEIT");         //prints line then product of Faren calculated from user input         System.out.println("I hope you aren't to cold or hot!");//prints line on screen after every conversion        }}}}// ends all code blocks of which there are three not ended inside the code and the entire code = }}}}            /** good information on java.util.Scanner can be found here -            **www.cs.williams.edu/~jeannie/cs136/scanner.pdf            **other java info can be found here -            **http://bucarotechelp.com/design/jseasy/96012902.asp            **This code and accompanying tutorial comments are free information for all to use. No credit required**/ 
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment