Results 1 to 2 of 2

Thread: need help ...

  1. #1
    MrDayen is offline Member
    Join Date
    Jun 2014
    Posts
    1
    Rep Power
    0

    Default need help ...

    i need to make the input go to hitungluas and hitungkeliling but ,... its not ,... im new ,... and this is a task for my class ,.. tq and sorry if i do wrong in this forum . tq




    Java Code:
    import java.util.Scanner;
    
    class Lingkaran {
    	double jari;
    	void lingkaran() {
    		setJari(1);		
    	}
    	void setJari(double r){
    		if(r>0) jari=r;		
    	}
    	public double getJari() {
    		return(jari);
    	}
    	public double hitungLuas() {
    		return(Math.PI*jari*jari);
    	}
    	public double hitungKeliling() {
    		return(Math.PI*jari*2.0);
    	}
    }
    
    class demolingkaran {
    	private static Scanner baca;
    	public static void main(String[] args) {
    		baca = new Scanner(System.in);
    		
    		Lingkaran abc=new Lingkaran();
    		Lingkaran pqr=new Lingkaran();
    		Lingkaran xyz=new Lingkaran();
    		System.out.println("Data Default");
    		System.out.println("------------");
    		System.out.println("jari-jari ABC :"+abc.getJari());
    		System.out.println("jari-jari PQR :"+pqr.getJari());
    		System.out.println("jari-jari xyz :"+xyz.getJari());
    		System.out.println();
    		System.out.print("Masukkan Jari-jari Lingkaran ABC = ");
            abc.jari = baca.nextDouble();
            System.out.print("Masukkan Jari-jari Lingkaran PQR = ");
            pqr.jari = baca.nextDouble();
            System.out.print("Masukkan Jari-jari Lingkaran XYZ = ");
            xyz.jari = baca.nextDouble();
    		System.out.println("Data Current");
    		System.out.println("------------");
    		System.out.println("jari-jari ABC :"+abc.getJari());
    		System.out.println("jari-jari PQR :"+pqr.getJari());
    		System.out.println("jari-jari xyz :"+xyz.getJari());
    	}
    }
    Last edited by MrDayen; 06-05-2014 at 01:38 AM.

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,002
    Rep Power
    20

    Default Re: need help ...

    When posting code please wrap it in [code] tags [/code] so it retains its formatting.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •