package basic;
import javax.swing.JOptionPane;
public class Basic {
public static void main(String[] args) {
String Faren;
double faren;
double cel;
Faren = JOptionPane.showInputDialog(" put the temperature of farenheit");
faren = Double.parseDouble(Faren);
cel = (faren-32.0)* (5.0/9.0);
System.out.println("faren temp" + faren);
System.out.println("cel temp" + cel);
}
}
ProjectKoolit Java
Martes, Pebrero 7, 2012
basic 37: String concat
package basicforjava;
public class Basicforjava {
public static void main(String[] args){
String str1 = "manny";
String str2 = "pakyaw";
String name = str1 + " " + str2;
System.out.println(name+ " hahahaha");
}
public class Basicforjava {
public static void main(String[] args){
String str1 = "manny";
String str2 = "pakyaw";
String name = str1 + " " + str2;
System.out.println(name+ " hahahaha");
}
basic 36: int from string
package basicforjava;
public class Basicforjava {
public static void main(String[] args) {
String yahoo = "300";
int i = Integer.parseInt(yahoo);
int sum = i - 10;
System.out.println("Integer value= " + sum);
}
}
public class Basicforjava {
public static void main(String[] args) {
String yahoo = "300";
int i = Integer.parseInt(yahoo);
int sum = i - 10;
System.out.println("Integer value= " + sum);
}
}
basic 35: Array sort
package basic3;
import java.util.Arrays;
public class Basic3 {
public static void main(String[] args) {
String[] names = {"Zoel", "Alisona", "Ray"};
Arrays.sort(names);
System.out.println(Arrays.toString(names));
double[] lengths = {12.0, 10.5, 1.0, 999.0, 77.5};
Arrays.sort(lengths);
System.out.println(Arrays.toString(lengths));
}
}
import java.util.Arrays;
public class Basic3 {
public static void main(String[] args) {
String[] names = {"Zoel", "Alisona", "Ray"};
Arrays.sort(names);
System.out.println(Arrays.toString(names));
double[] lengths = {12.0, 10.5, 1.0, 999.0, 77.5};
Arrays.sort(lengths);
System.out.println(Arrays.toString(lengths));
}
}
basic 34: table for multidimensional array
package basic;
public class Basic {
public static void main(String[] args) {
int array1[][] = {{1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}};
int array2[][] = {{11, 12, 13, 14, 15}, {16, 17, 18,}};
System.out.println("this is th 1st array");
display(array1);
System.out.println("this is the 2nd array");
display(array2);
}
public static void display(int x[][]) {
for (int row = 0; row < x.length; row++) {
for (int column = 0; column < x[row].length; column++) {
System.out.print(x[row][column] + "\t ");
}
System.out.println("");
}
}
}
public class Basic {
public static void main(String[] args) {
int array1[][] = {{1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}};
int array2[][] = {{11, 12, 13, 14, 15}, {16, 17, 18,}};
System.out.println("this is th 1st array");
display(array1);
System.out.println("this is the 2nd array");
display(array2);
}
public static void display(int x[][]) {
for (int row = 0; row < x.length; row++) {
for (int column = 0; column < x[row].length; column++) {
System.out.print(x[row][column] + "\t ");
}
System.out.println("");
}
}
}
basic 33:multidimensional array
package basic;
public class basic2 {
public static void main(String[] args) {
int array1[][] = {{1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}};
int array2[][] = {{11, 12, 13, 14, 15}, {16, 17, 18,}};
yahoo(array1);
yahoo(array2);
}
public static void yahoo(int x[][]) {
for (int row = 0; row < x.length; row++) {
for (int column = 0; column < x[row].length; column++) {
System.out.println(x[row][column]);
}
}
}
}
public class basic2 {
public static void main(String[] args) {
int array1[][] = {{1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}};
int array2[][] = {{11, 12, 13, 14, 15}, {16, 17, 18,}};
yahoo(array1);
yahoo(array2);
}
public static void yahoo(int x[][]) {
for (int row = 0; row < x.length; row++) {
for (int column = 0; column < x[row].length; column++) {
System.out.println(x[row][column]);
}
}
}
}
basic 32: array method (hard)
package basic;
public class Basic {
public static void main(String[] args) {
int val[] = {1, 2, 3, 4, 5, 6, 7};
newval(val);
for (int y : val) {
System.out.println(y);
}
}
public static void newval(int x[]) {
for (int i = 0; i < x.length; i++) {
x[i] += 10;
}
}
}
public class Basic {
public static void main(String[] args) {
int val[] = {1, 2, 3, 4, 5, 6, 7};
newval(val);
for (int y : val) {
System.out.println(y);
}
}
public static void newval(int x[]) {
for (int i = 0; i < x.length; i++) {
x[i] += 10;
}
}
}
Mag-subscribe sa:
Mga Post (Atom)