BlueJ
public static void main(String[] args) { . . . }
main()
//******************************************************************** // TempConverter.java Author: Lewis/Loftus // // Demonstrates the use of primitive data types and arithmetic // expressions. //******************************************************************** public class TempConverter { //----------------------------------------------------------------- // Computes the Fahrenheit equivalent of a specific Celsius // value using the formula F = (9/5)C + 32. //----------------------------------------------------------------- public static void main (String[] args) { final int BASE = 32; final double CONVERSION_FACTOR = 9.0 / 5.0; int celsiusTemp; double fahrenheitTemp; celsiusTemp = 24; // value to convert fahrenheitTemp = celsiusTemp * CONVERSION_FACTOR + BASE; System.out.println ("Celsius Temperature: " + celsiusTemp); System.out.println ("Fahrenheit Equivalent: " + fahrenheitTemp); } }
SimpleDate.test()
StockDemo.demo()
''
String name = "";
System.out.println("Hi, " + name + '!');
char
int
String
char ch;
ch = 'e';
System.out.println("I guess: " + ch);
char ch0 = '\t', ch1 = 'a', ch2 = '\n', ch3 = 'c', ch4 = '\\';
char Character.toUpperCase(char)
char Character.toLowerCase(char)
'r'
'R'
char ch1, ch2, ch3, ch4, ch5; ch1 = 'g'; ch2 = Character.toUpperCase(ch1); // now |ch2| is ch3 = Character.toUpperCase(ch2); // already uppercase -- get same back: ch4 = '%'; ch5 = Character.toUpperCase(ch4); // not a letter -- get same char. back: '%'
public class program_name { public static void main(String[] args) { declarations int n; double r; other_statements // Use |scanner.nextInt()| to input an |int| // or |scanner.nextDouble()| to input a |double| other_statements } }
/** * Demonstrates the use of primitive data types and arithmetic * expressions. * * @author Lewis/Loftus */ public class TempConverter { public static void main(String[] args) { final int BASE = 32; final double CONVERSION_FACTOR = 9.0 / 5.0; System.out.print("Enter Celsius Temperature: "); double celsiusTemp System.out.println(); double fahrenheitTemp; fahrenheitTemp = celsiusTemp * CONVERSION_FACTOR + BASE; System.out.println ("Celsius Temperature: " + celsiusTemp); System.out.println("Fahrenheit Equivalent: " + fahrenheitTemp); } }
System.out.println()
System.out.print()
String s = scanner.nextLine(); char ch = scanner.nextLine().charAt(0);