Pages

Selasa, 07 Juni 2011

MENCARI KUADRAT



import java.util.Scanner;
public class kuadrat{
    public static void main (String [] args){
        Scanner input= new Scanner(System.in);
        garis();
        System.out.println("       MENU PILIHAN   ");
        garis();
        System.out.println("1. MENGHITUNG KUADRAT");
        System.out.println("");
        System.out.println("2. EXIT");
        garis();
          System.out.println("Anda pilih nomor :");
          int pil=input.nextInt();
          switch (pil){
              case 1:{
                   System.out.println(" Menghitung mahasiswa");
                     System.out.println("Masukan datanya :");

                 int n=input.nextInt();
         int[]data=new int[10];
         for(int i=1;i<=n;i++){
              System.out.println("Data ke"+i+"=");

              System.out.println("angka :"); int angka=input.nextInt();
            
              int kuadrat = angka*angka;
               System.out.println("hasil kuadrat :" +kuadrat);
               System.out.println(" ");

             
         }
         break;
              }
              default:System.exit(0);
          }}
    static void garis(){
        System.out.println("--------------------------");

                         }


         }

0 komentar:

Posting Komentar