0% found this document useful (0 votes)
92 views4 pages

Laporan Akhir Praktikum Pemrograman Berorientasi Objek: Disusun Oleh

This document contains the source code for two programs: a phone buying and selling program and a student data program. The phone program uses string and integer variables for color, brand and price, while the student program uses string and integer variables for name, address, email, and student ID. When run, both programs will display the input data in a formatted output. The document also includes images showing example output of the programs.

Uploaded by

Moch Yuwan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
92 views4 pages

Laporan Akhir Praktikum Pemrograman Berorientasi Objek: Disusun Oleh

This document contains the source code for two programs: a phone buying and selling program and a student data program. The phone program uses string and integer variables for color, brand and price, while the student program uses string and integer variables for name, address, email, and student ID. When run, both programs will display the input data in a formatted output. The document also includes images showing example output of the programs.

Uploaded by

Moch Yuwan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

LAPORAN AKHIR PRAKTIKUM

PEMROGRAMAN BERORIENTASI OBJEK

DISUSUN OLEH

Nama Lengkap : Mia Rosmeida


NIM : 201804008
Prodi : Teknologi Rekayasa Perangkat Lunak
Mata Praktikum : Pemrograman Berorientasi Objek
Praktikum ke- :2
Materi : Java
Dosen / Asisten : Muhammad Nugraha S.T.,M.Eng.,

LABORATORIUM TEKNOLOGI REKAYASA PERANGKAT LUNAK


POLITEKNIK ENJINERING INDORAMA
2019
Source Code Handphone
package hp;
public class Handphone {
String warna, merk;
int harga;
void membeli()
{
System.out.println(" ------------------");
System.out.println("Warna = " +warna);
System.out.println("Merk = " +merk);
System.out.println("Harga = Rp." +harga);
}
void menjual()
{
System.out.println(" ------------------");
System.out.println("Warna = " +warna);
System.out.println("Merk = " +merk);
System.out.println("Harga = Rp." +harga);
}
}
package hp;

import java.util.Scanner;

public class HandphoneBeraksi {


public static void main(String[] args) {
Scanner m = new Scanner(System.in);
Scanner mm = new Scanner(System.in);

Handphone h = new Handphone();


Handphone oppo = new Handphone();
System.out.println("WELCOME TO MIA STORE PHONE");
System.out.println("-------------- Membeli --------------");
System.out.print("Masukan Warna Hp = ");
h.warna = m.nextLine();
System.out.print("Masukan Merk Hp = ");
h.merk = m.nextLine();
System.out.print("Masukan Harga Hp = Rp.");
h.harga = mm.nextInt();
h.membeli();
System.out.println("-------------- Menjual --------------");
System.out.print("Masukan Warna Hp = ");
oppo.warna = m.nextLine();
System.out.print("Masukan Merk Hp = ");
oppo.merk = m.nextLine();
System.out.print("Masukan Harga Hp = Rp.");
oppo.harga = mm.nextInt();
oppo.menjual();
}
}

Tampilan diatas merupakan source code dari program menjual dan membeli handphone
yang menggunakan 2 tipe data yaitu integer dan string dengan menggunakan 3 variabel yaitu
warna, merk dan harga. Ketika program dirunning maka akan menampilkan tampilan seperti
gambar 1.
Gambar 1. Tampilan output program menjual dan membeli handphone

Source Code
package Mahasiswa;
import java.util.Scanner;
public class Mahasiswa {

String nama,alamat,email;
int nim;
Scanner m = new Scanner(System.in);
Scanner mm = new Scanner(System.in);

void mencetak()
{
System.out.println("-------------- Mencetak --------------");
System.out.println("NIM = " +nim);
System.out.println("Nama = " +nama);
System.out.println("Alamat = " +alamat);
System.out.println("Email = " +email);
}
void mengisi()
{
System.out.println("--------------- Mengisi --------------");
System.out.print("Masukan NIM = ");
nim = m.nextInt();
System.out.print("Masukan Nama = ");
nama = mm.nextLine();
System.out.print("Masukan Alamat = ");
alamat = mm.nextLine();
System.out.print("Masukan Email = ");
email = mm.nextLine();
}

}
package Mahasiswa;

public class MahasiswaBeraksi {


public static void main(String[] args){
Mahasiswa h=new Mahasiswa();
h.mengisi();
h.mencetak();
}
}

Tampilan diatas merupakan source code dari program mengisi dan mencetak data
mahasiswa yang menggunakan 2 tipe data yaitu integer dan string dengan menggunakan 4
variabel yaitu nim, nama, email dan alamat. Ketika program dirunning maka akan
menampilkan tampilan seperti gambar 2.

Gambar 2. Tampilan output program data Mahasiswa

You might also like