Mod3.docx

  • Uploaded by: fuad
  • 0
  • 0
  • December 2019
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Mod3.docx as PDF for free.

More details

  • Words: 225
  • Pages: 3
Tugas Praktikum package package1; import java.util.Scanner;

public class inputan extends inisial{ int jumlah,i,n,x; String kata; boolean boll=false; Scanner input = new Scanner(System.in); public void inputan()throws Exception { System.out.print("Masukkan Jumlah = "); jumlah=input.nextInt(); for(i=1; i<=jumlah; i++){ do { try{ System.out.print("Masukkan Kata"+i+" : "); kata=input.next(); int x; for(char n:kata.toCharArray()) { x=(int)n; if(!((x>=97 && x<=122) || (x>=65 &&x<=90) || (x>=48 && x<=57) )) { throw new Exception("Tulisan Mengandung simbol"); } }

boll=false; } catch (Exception ex) { System.out.println (ex.getMessage()); boll=true; }

Pemrograman Berorientasi Objek | Periode II | Tahun 2017/2018 | Lab. Rekayasa Perangkat Lunak

Tugas Praktikum }while(boll); setKata(kata,i); } System.out.println("Jumlah = "+jumlah); for (int i=1;i<=jumlah;i++) { n=i+1; for (int j = 2; j <=jumlah+1-i; j++) { System.out.print("Kata "+i+" sama dengan kata "+n+" : "); try { Thread.sleep(1000); } catch (Exception e) { } if(getKata(i).equals(getKata(n))) { System.out.print("True\n"); } else { System.out.print("False\n"); } n++; } } } }

Pemrograman Berorientasi Objek | Periode II | Tahun 2017/2018 | Lab. Rekayasa Perangkat Lunak

Tugas Praktikum package package1; public class inisial { private static String[] kata=new String[100]; protected void setKata(String kata,int i) { this.kata[i]=kata; } protected String getKata(int i) { return this.kata[i]; } }

package package1; import package1.*;

public class utama { public static void main(String[] args) throws Exception{ inputan ip = new inputan(); ip.inputan(); } }

Pemrograman Berorientasi Objek | Periode II | Tahun 2017/2018 | Lab. Rekayasa Perangkat Lunak

More Documents from "fuad"

May 2020 13
May 2020 16
May 2020 17
Mod3.docx
December 2019 23
Bahaya Rokok
June 2020 22
May 2020 13