contoh program java sederhana
Blog ini saya buat untuk share contoh-contoh program java sederhana. Semoga bermanfaat
Selasa, 24 April 2012
membaca input dari file
import java.io.*;
import java.util.*;
public class Main {
public static void main (String[] args)throws FileNotFoundException {
try {
double n1, n2, n3;
String n;
Scanner fileInput = new Scanner(new FileReader("nilai.txt"));
PrintWriter outFile = new PrintWriter("hasil.out");
System.out.println("mulai scanner file");
try {
while (fileInput.hasNext()) {
String line = fileInput.nextLine();
Scanner lineScan = new Scanner(line);
lineScan.useDelimiter(";");
n = lineScan.next();
n1 = lineScan.nextDouble();
n2 = lineScan.nextDouble();
n3 = lineScan.nextDouble();
double average=(n1+n2+n3)/3;
outFile.println(n+";"+average);
} } catch (Exception e) {
System.out.println("scan file error");
}
fileInput.close();
outFile.close();
System.out.println("berhasil scanner file, hasil output akan dicetak di hasil.txt");
} catch (FileNotFoundException fnfex) {
System.out.println("File does not exist!!");
}
}
}
matriks orthogonal
import java.util.Scanner;
public class array
{
public static void main(String[] args) {
//deklarasi variabel array dan penciptaan
Double array[][]=new Double [2][2];
Scanner scan=new Scanner(System.in);
System.out.println("Masukkan nilai matriks baris 1 kolom 1: ");
array[0][0]=scan.nextDouble();
System.out.println("Masukkan nilai matriks baris 1 kolom 2: ");
array[0][1]=scan.nextDouble();
System.out.println("Masukkan nilai matriks baris 2 kolom 1: ");
array[1][0]=scan.nextDouble();
System.out.println("Masukkan nilai matriks baris 2 kolom 2: ");
array[1][1]=scan.nextDouble();
kalkulator sederhana (handling exception)
import java.util.*;
public class kalkulator
{
// method operasi kali
public int kali(int a, int b){
int c= a*b;
return c;
}
// method operasi bagi
public float bagi(float a, float b){
float c= a/b;
return c;
}
//method operasi pangkat
public int pangkat(int a, int b){
int c=(int) Math.pow(a,b);
return c;
}
Sabtu, 07 Januari 2012
coding kalkulator binary sederhana
package FloatingPoint;
import com.sun.java.swing.plaf.windows.WindowsLookAndFeel;
import java.math.BigDecimal;
import java.math.BigInteger;
import javax.swing.JFrame;
import javax.swing.UIManager;
public class FloatingPoint extends javax.swing.JFrame {
private int numExponent = 8;
private int numMantissa = 23;
private int bitLength;
private int bias;
private final String[] HEX = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F"};
private String zero;
int eksponen = 8;
int mantissa = 23;
int sumber, one, two;
String hasil;
String OC = "1";
String chi;
import com.sun.java.swing.plaf.windows.WindowsLookAndFeel;
import java.math.BigDecimal;
import java.math.BigInteger;
import javax.swing.JFrame;
import javax.swing.UIManager;
public class FloatingPoint extends javax.swing.JFrame {
private int numExponent = 8;
private int numMantissa = 23;
private int bitLength;
private int bias;
private final String[] HEX = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F"};
private String zero;
int eksponen = 8;
int mantissa = 23;
int sumber, one, two;
String hasil;
String OC = "1";
String chi;
linked list (insert)
package linklist_insert;
import java.util.*;
/**
*
* @author Compaq
*/
public class Main {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
System.out.println("LinkedList");
LinkedList List=new LinkedList();
int a=3, b=5, c=9, d=11;
int size;
import java.util.*;
/**
*
* @author Compaq
*/
public class Main {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
System.out.println("LinkedList");
LinkedList List=new LinkedList();
int a=3, b=5, c=9, d=11;
int size;
Selasa, 03 Januari 2012
remove windows not genuine
In this article we will learn how to make your Windows 7 Genuine without using any crack or third party tools. Please remember we on bench3 do not motivate you to use non genuine windows. This is not a patch or crack stuff. We are just using the build in VBS code that Microsoft have developed for some other reason.
Warning! This article has been given only for informational and educational purpose. We do not encourage pirated or illegal software. If you’re using an illegal copy of the software, please purchase an original copy. bench3 is not responsible for your work or use.
The first time you power up Windows 7, you may feel a sense — it looks very similar to Windows Vista. However, behind the familiar UI lies a more powerful and versatile operating system. The activation part is not the same as you know in case of Windows Vista. What ever it is, if you want to know the new features of Windows 7, Here are some of the most prominent new features in Windows 7.
If you have purchased Windows 7 from Microsoft Store or from other vendor, we would recommend you to read the official document related to activating Microsoft Windows 7 in the following location.http://windows.microsoft.com/en-IN/windows7/Windows-7-activation-error-invalid-product-key
Here is an simple way u can make your windows 7 genuine. No need to use and third party patches or cracks. Just a simple way.
Jumat, 30 Desember 2011
Windows 7 Activation Steps
What is Windows activation?
Activating Windows 7 installation is in a way registering Windows 7 operating system of yours and making it legal.
Since Microsoft is keeping their rights on their various products including Windows products using the genius activation method, as a Windows 7 user, you should also activate Windows 7 copy of your own within a given period using one of different methods.
Why activating Windows 7 is important?
Microsoft operating systems had this feature on Windows Vista editions as well as on Windows 7 editions with different Windows 7 Build 's until its RTM release is published.
And windows activation which is not completed in the given period of time disables some Windows features and prevents you to use all properties of your system after the activation period.
Also you may not be able to update your system with the recent product updatsd from Microsoft.
So to make sure that you can benefit from all the feaures and enhancements of your Microsoft Windows 7 operating system, give priority to activate Windows7 as early as possible.
If you have already tried to activate Windows 7 copy, but failed and getting "This copy of Windows 7 is not genuine" warning then you can refer to Windows 7 troubleshoot article Windows 7 Activation - This copy of Windows 7 is not genuine for possible solution suggesstions.
Langganan:
Postingan (Atom)