Tugas Syntax Dasar Object Oriented Programming

· OOP1
Penulis

Program C#

namespace Tugas_OOP_Prsentasi_tgl_8

{

class Program

{

static void Main(string[] args)

{

string nama;

string jenis_kelamin;

string alamat;

{

Console.Write(“Masukkan nama=”);

nama = Console.ReadLine();

Console.Write(“Masukkan jenis kelamin=”);

jenis_kelamin = Console.ReadLine();

Console.Write(“Masukkan alamat=”);

alamat = Console.ReadLine();

Console.WriteLine();

Console.WriteLine(“Nama anda adalah {0}”, nama);

Console.WriteLine(“Jenis kelamin anda adalah {0}”, jenis_kelamin);

Console.WriteLine(“Alamat anda adalah {0}”, alamat);

Console.Write(“Press any key to continue..!”);

Console.ReadKey();

}

}

}

}

Image

Program C++

using namespace std;
class rumus{
private:
int tinggi, sedang, pendek;
public:
void input(int a, int b){
tinggi=a;
sedang=b;
pendek=tinggi * sedang;
}
void hasil()
{
cout<<pendek;
}
};

int main(int argc, char *argv[]){
int x,y,z;
rumus blue;
cout << “tnggi = “;
cin >> x;
cout << “sedang = “;
cin >> y;

blue.input(x,y);
cout << endl;
cout << “Luas = “;
blue.hasil();
cout << endl;

system(“PAUSE”);
return EXIT_SUCCESS;
}

Hasilnya;

Program Java

package javaapplication8;
import java.util.Scanner;
class rumus {
public void input(int a, int b){
int tinggi,sedang,kurus;
tinggi=a;
sedang=b;
kurus= tinggi * sedang;
System.out.println(kurus);
}
}
public class Main {

public static void main(String[] args) {
Scanner input=new Scanner(System.in);
rumus blue=new rumus();
int tinggi, sedang;
System.out.print(“tinggi = “);
tinggi=input.nextInt();
System.out.print(“sedang = “);
sedang=input.nextInt();
System.out.print(“kurus = “);
blue.input(sedang, sedang);
System.out.println();
}

}

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s

%d blogger menyukai ini: