Tampilkan postingan dengan label Tugas Alpro. Tampilkan semua postingan
Tampilkan postingan dengan label Tugas Alpro. Tampilkan semua postingan

Rabu, 24 April 2013

Raptor "Deret aritmatika going up"

Ini adalah raptor dari menentukan suatu deret aritmatika dengan going-up rekursif.Going up rekursif disini berarti parameter menaik nilainya hingga kasusnya berhenti. lalu dari seluruh deret dilakukan penjumlahan.

Contoh:
nilai awal= 2
beda= 1
banyak deret= 5
maka:
2+3+4+5+6=20

Berikut raptornya:
main program




















going up rekursif


















Selasa, 23 April 2013

Raptor menentukan nilai faktorial dengan going down rekursif

Ini adalah raptor dari menentukan nilai faktorial dengan going-down rekursif.
Berbeda dengan going up yg sebelumnya saya posting,
Going down rekursif disini berarti parameter menurun nilainya hingga kasusnya berhenti.
Contoh:
5!
maka:
5!=5x4x3x2x1=120

Berikut raptornya:
Main program


















Going down rekursif

Raptor menentukan nilai faktorial dengan going-up rekursif

Ini adalah raptor dari menentukan nilai faktoria dengan going-up rekursif.
Going up rekursif disini berarti parameter menaik nilainya hingga kasusnya berhenti.
Contoh:
5!
maka:
5!=1x2x3x4x5=120

Berikut raptornya:

Main program



















going up faktorial

Studi kasus "Raptor Mencari huruf kapital dalam string yang di inputkan dengan rekursif"

Berikut ini adalah gambar flowchart  dari sebuah studi kasus yang kelompok kami dapatkan dari bab 9 pada ebook untuk alpro.
Kasus yang ada disini adalah bagaimana cara kita untuk mendeteksi/mencari suatu huruf kapital dalam sebuah string yang di inputkan.
Disini diperlukan suatu fungsi dalam raptor, yaitu fungsi length_of yang mengembalikan jumlah karakter dalam sebuah variabel string (juga jumlah elemen dengan sebuah array), contoh : Nama ← “ejha” diikuti dengan Length_Of (Nama) adalah 4.
Berikut adalah raptornya, dengan cara rekursif.


Main program 
konversi(a,i,in,string)
                                    

Senin, 08 April 2013

Quiz Alpro "Menyebutkan angka yang di inputkan dalam bentuk huruf"

Berikut adalah jawaban dari quiz alpro yang diberikan oleh dosen pada hari sabtu kemarin. Karena waktu dan kegugupan, belum saya selesaikan di kelas.... -_-'' menyebalkan..
Ini adalah raptor untuk menyebutkan angka yang di inputkan dalam bentuk huruf/kata.
Contoh:
Input: 123
Output: seratus dua puluh tiga.

Program Raptornya dapat didownload disini: http://www.ziddu.com/download/21971913/QuizAlpro.zip.html

Ini adalah output saat menginputkan "123" dan juga saat menginputkan "536"



Jumat, 05 April 2013

Kasus 4.2 "Algoritma mencetak bilangan ganjil dari 0 sampai 10"

Masalah:
  • Buatlah Algoritma mencetak bilangan ganjil dari 0 sampai 10
Deklarasi:
  • i : Integer{Input,Output}
Deskripsi
  • read(i=0)
  • for i<-0 to 10 do
     if(i mod 2=1)
     then write(i)
     endif
    endfor
 
Gambar Flowchart:

Sabtu, 23 Maret 2013

Kasus 3.5 "Algoritma Konversi Hari"


Masalah:
  • Konversikan hari ke 1 adalah hari senin sampai dengan hari ke-7 adalah hari minggu
Analisis:
  • Input: hari_ke
  • Proses: mengkonversi nilai angka menjadi nama hari
  • Output: Hasil konversi angka menjadi hari
Deklarasi:
  • hari_ke : integer{Input}
  • hari : string{Output}
Deskripsi:
  • read(hari_ke)
  • pilih(hari_ke) untuk
    1:hari<--"Senin"
    2:hari<--"Selasa"
    3:hari<--"Rabu"
    4:hari<--"Kamis"
    5:hari<--"Jum'at"
    6:hari<--"Sabtu"
    else hari<--"Minggu"
    end{pilih}
  • write(hari)
Gambar Flowchart:



Program C++ Konversi hari:

#include<iostream.h>
#include<conio.h>
using namespace std;

main(){
int hari_ke;
char *hari;
cout<<"Masukkan hari ke-";cin>>hari_ke;

switch(hari_ke){
case 1: strcpy(hari, "Senin");break;
case 2: strcpy(hari, "Selasa");break;
case 1: strcpy(hari, "Rabu");break;
case 1: strcpy(hari, "Kamis");break;
case 1: strcpy(hari, "Jumat");break;
case 1: strcpy(hari, "Sabtu");break;
default: strpy(hari, "Minggu");break;
}

cout<<"Hari ke-"<<hari_ke<<"Adalah"<<hati<<endl;

return 0;
}

Kasus 3.4 "Konversi Nilai"

Masalah:
  • Konversikan nilai angka menjadi nilai huruf, sesuai ketentuan dibawah ini:
Nilai Angka            Nilai Huruf
    0-20                          A
   20-40                         B
   40-60                         C
   60-80                         D
   80-100                       E

Analisis:

  • Input: nilai
  • Proses: mengkonversi nilai angka menjadi nilai huruf.
  • Output: Hasil konversi nilai
Deklarasi:

  • nilai : integer{Input}
  • nilai_huruf : char{Output}
Deskripsi:

  • read(nilai)
  • if (nilai>0) and (nilai<=20) then nilai_huruf<--'E'
    else if(nilai>20) and (nilai<=40) then nilai_huruf<--'D'
    else if(nilai>40) and (nilai<=60) then nilai_huruf<--'C'
    else if(nilai>60) and (nilai<=80) then nilai_huruf<--'B'
    else then nilai_huruf<--'A'
    endif
  • write(nilai_huruf)
Gambar Flowchart:


Program C++ Konversi nilai angka ke nilai huruf:


#include<iostream.h>
using namespace std;

main(){
int nilai;
char nilai_huruf;
cout<<"Masukkan nilai angka=";cin>>nilai;

if((nilai>0)&&(nilai<=20)) nilai_huruf='E';
else if((nilai>20)&&(nilai<=40)) nilai_huruf='D';
else if((nilai>40)&&(nilai<=60)) nilai_huruf='C';
else if((nilai>60)&&(nilai<=80)) nilai_huruf='B';
else nilai_huruf='A';

cout<<"Nilai huruf="<<nilai_huruf;

return 0;
}

Kasus 3.3 "Algoritma Menghitung akar-akar persamaan kuadrat"

Masalah:
  • Buatlah algoritma mencari akar-akar persamaan kuadratnya
Analisis:
  • Input: a,b,c
  • Proses: mencari akar-akar persamaan kuadrat.
  • Output: akar-akar kuadrat
Deklarasi:
  • a,b,c : integer{Input}
  • disk : longint{output}
  • x1,x2 : real{output}
Deskripsi:
  • read(a,b,c)
  • disk<--b*b-4a*c
  • if (a=0) then write('Bukan persamaan kuadrat')
    else if disk>0 then
      x1<---(-b)+sqrt(disk)/2*a
      x2<---(-b)-sqrt(disk)/2*a
    else if disk=0 then
      x1<---(-b)/2*a
      x2<---x1
    else write('Akar Imajiner')
    end if
  • write(x1,x2)


Gambar Flowchart:


Program C++ Menghitung akar-akar persamaan kuadrat:

#include<cstdlib>
#include<iostream>
#include <conio.h>
#include<math.h>
using namespace std;

class persamaan{

public:
void persamaan_kuadrat();
float rumus();
private:
int x,y,z;
float x1,x2;
float disk;
};

void persamaan::persamaan_kuadrat(){
cout<<"masukkan nilai A :";
cin>>x;
cout<<"masukkan nilai B :";
cin>>y;
cout<<"masukkan nilai C :";
cin>>z;

}
float persamaan::rumus(){
disk=y*y-4*x*z;

if (disk>0)
{
cout<<"Diskriminan="<<disk<<" Maka akar-akarnya adalah:"<<endl;
x1=(-y+(sqrt(disk)))/(2*x);
cout<<"x1 :"<<x1;
cout<<endl;
x2=(-y-(sqrt(disk)))/(2*x);
cout<<"x2 :"<<x2;
}
else if(disk=0)
{
cout<<"Diskriminan="<<disk<<" Maka akar-akarnya adalah:"<<endl;
x1=-y/2*x;
cout<<"x1 :"<<x1;
cout<<endl;
x2=x1;
cout<<"x2 :"<<x2;
}
else
cout<<"akar imajiner";

}

int main(int argc, char *argv[])

{
persamaan X;
X.persamaan_kuadrat();
X.rumus();

return 0;

}

Kasus 3.2 "Menentukan bilangan terbesar antara 3

Masalah:

  • Buatlah Algoritma menentukan bilangan terbesar antara dua bilangan bulat
Analisis:

  • Input: x,y,z
  • Proses: membandingkan nilai terbesar antara x,y, dan z.
  • Output: Jika x>y>z, maka output=x. Jika y>x>z maka output=y. Jika z>x>y maka output=z.
Deklarasi:

  • x,y,z : Integer{Input}
  • x atau y atau z : Integer{Output}
Deskripsi

  • read(x,y,z)
  • if(x>y) and (x>z) then write('Bilangan terbesar adalah='x)
    else if (y>x) adn (y>z) then write('Bilangan terbesar adalah='y)
    else write('Bilangan terbesar adalah='z)
Gambar Flowchart:




Program C++ menentukan bilangan terbesar antara tiga bilangan bulat

#include<cstdlib>
#include<iostream>
#include <conio.h>
#include<math.h>
using namespace std;

class banding{

public:
void banding_3_bilbulat();

private:

int x,y,z;

};

void banding::banding_3_bilbulat(){
cout<<"masukkan nilai x :";
cin>>x;
cout<<"masukkan nilai y :";
cin>>y;
cout<<"masukkan nilai z :";
cin>>z;
cout<<endl;
{
if((x>y)&&(x>z))
cout<<"Bilangan terbesar adalah x";
else if((y>z)&&(y>x))
cout<<"Bilangan terbesar adalah y";
else
cout<<"Bilangan terbesar adalah z";
}

}


int main(int argc, char *argv[])

{

banding X;
X.banding_3_bilbulat();


return 0;

}

Tugas meringkas Alpro "Top-Down Design with Functions"

Programers use software development methods to solve the problem. Normally, programmers handle every new program as a unique event.

Building programs from existing information

Develop your program solutions from existing information. Use the system documentation derived from applying the software development method as the initial framework for the program.
  • Edit the data requirements to obtain the main function declarations. 
  • Use the refined algorithm as the starting point for the executable statements in the main function.
If a new problem is an extension of a previous one, modify the previous program rather than starting from scratch.

Tugas Meringkas Alpro "Overview of C"

This chapter will introduce C- as a high level programming language developed in 1972 by Dennis Ritchie at AT&T Bell Laboratories.

C Language Elements

Preprocessor Directive

Preoprocessor directive are commands that give instruction to C preprocessor, whose jobs it is to modify the text of a C program before it compiled. A preprocessor directive begin with symbol (#) as it first nonblank character. Example: #include, or #define

Jumat, 22 Maret 2013

Tugas meringkas Alpro "Overview of computers and programming"

This chapter will introduce about computer, and its component, and major category of programming languages. We will discuss how C programs are processed by computer, and also describe a systematic approach to solving programming problems called software developed method.

Kasus 3.1 "Menentukan Bilangan terbesar antara dua bilangan bulat"

Masalah:
  • Tentukanlah bilangan terbesar antara dua bilangan bulat.
Analisis:
  • Input: a,b
  • proses: membandingkan nilai terbesar antara a dan b.
  • Output: Jika a>b, maka output=a, Jika b>a, maka output=b.
Deklarasi:
  • a,b : Integer{Input}
  • a atau b: Integer {Output}
Deskripsi:
  • read(a,b)
  • If a>b, then write(a),
    else write(b)
 Gambar flowchart:


Program C++ Menentukan bilangan terbesar antara dua bilangan bulat.

#include<iostream.h>
 main()
{
   int a,b;
   cout<<"Masukkan bilangan pertama: ";
   cin>>a;
   cout<<"Masukkan bilangan kedua: ";
   cin>>b;
   if(a>b)
     cout<<"Bilangan terbesar= "<<a;
   else
    cout<<"Bilangan terbesar= "<<b;

 return 0;

}

Selasa, 19 Maret 2013

Tugas meringkas Alpro "Counting"

In this chapter, we will learn how to decide students who passed the examination and count it!
Lets Begin the summary!

Problem

  • Given a set of n students' examination marks(0-100). The students with mark 50 above declared passed the examination. Make count of students who passed the examination!

Algorithm development

Suppose that we are given the set of students marks
                           60, 39, 82, 59, 28, 64, 91
To make count of the passes students, we can start from the left. First mark is 60. We know that if mark >50, it means that students passed the examination. Now we have a student that passed. Remember it! The second mark are less than 50, it means that students not passed, and we dont need to count it. We still have 1 student passed. Look at the third mark, 82 is clearly passed examination. we can count it with the first one that already count. Process continues are similar like 3 students marks first until the last student.
Here are detail of count process:

Marks      >50=Pass       Counting details for passes
 60                  +1          (previous count=0)+1, current count=1
 39                  +0          (previous count=1)+0, current count=1
 82                  +1          (previous count=1)+1, current count=2
 59                  +1          (previous count=2+1), current count=3
 28                  +0          (previous count=3+0), current count=3
 64                  +1          (previous count=3+1), current count=4
 91                  +1          (previous count=4+1), current count=5

Algorithm Description

  1. Request and read the number of marks.
  2. Initialize count=0.
  3. Process  repeatedly for all marks: (a). Read next mark, (b). if mark>50, count as a pass and add 1 to count.
  4. write out total number of passes.

Pascal Implementation 


program passcount {input,output};
const passmark=50;
var count{contains number of passes on termination}
       i{current number of mark processed}
      m{current mark}
      n{total number of marks processed}: integer;
begin {count the number of passes (>=50) in a set of marks}
      writeIn ('enter a number of marks n on a separate line followed by the marks');
      readIn (n);
      {assert:n>=0}
      count := 0;
      i := 0;
      {invariant: count=number of marks in the first i read that are >= passmark ^i=<n}
       while i<n do
             begin{read next mark, test it for pass and update count if necessary}
               i := i+1;
               read(m);
               if eoIn (Input)then readIn;
               if m>=passmark then count := count+1
             end;
       {assert: count=number of passes in the set of n marks read}
       writeIn ('number of passes=',count)
end.

Senin, 18 Maret 2013

Latihan Individu "Algoritma menghitung determinan matriks 2x2"

Masalah:
  • Buatlah Algoritma dan flowchart untuk menghitung determinan matriks 2x2
Analisis:
  • Input: 4 buah nilai anggota matriks
  • Proses: Mencari nilai determinan dari 4 inputan anggota matriks
  • Output: Menampilkan hasil determinan.
Deklarasi:
  • a,b,c,d : Integer{Input}
  • hasil : Integer{Output}

Deskripsi:
  • read(a,b,c,d)
  • hasil<--(a*d)-(b*c)
  • write(hasil)

Gambar flowchart: 



Latihan Individu "Algoritma memisahkan komponen bilangan < 1000"

Masalah:
  • Buatlah Algoritma dan flowchart untuk memisahkan bilangan integer yang kurang dari 1000 menjadi komponen-komponennya.
Analisis:
  • Input: Bilangan Integer<1000
  • Proses: Memisahkan komponen penyusun bilangan yang di input.
  • Output: Menampilkan hasil pemisahan komponen-komponen bilangannya
Deklarasi:
  • nilai : Integer{Input}
  • Ratusan, puluhan, satuan : Integer{Output}

Deskripsi:
  • read(nilai)
  • Ratusan<-- ((nilai-(nilai%100))/100)
  • Puluhan<--(((nilai-(nilai%10)%100)/10)
  • Satuan<--nilai%10
  • write(Ratusan,puluhan,satuan)

Gambar Flowchart:
Berikut adalah hasil flowchart diatas saat meng-inputkan bilangan 589:

Latihan Individu "Algoritma Mencari titik tengah sebuah garis"

Masalah:
  • Buatlah Algoritma dan flowchart untuk mencari titik tengah sebuah garis yang ujung titiknya adalah A(x1,y1) dan B(x2,y2)
Analisis:
  • Input: 4 buah titik(x1,x1,y1,y2)
  • Proses: Mencari titik tengah
  • Output: Titik tengah dari 4 titik awal. (x,y)
Deklarasi:
  • x1, x2, y1, y2 : Integer {Input}
  • x,y : Integer {Output}
Deskripsi:
  • Read(x1,x2,y1,y2)
  • x<-- (x1+x2)/2
  • y<--(y1+y2)/2
  • Write(x,y)

Gambar Flowchart:


Jumat, 15 Maret 2013

Tugas Alpro Ringkasan "Computer science as a Career path"

In this chapter, we have 3 section:
  1. Why Computer science may be the right field for you
  2. The College Experience: Computer Disciplines and majors to choose from
  3. Career Opportunities
Lets begin the summary!

Section 1 "Why Computer Science May be the Right Field for You"


Reason to major in computer science


Our question is "Why?" Reason is, because the computer industry is one of the fastest growing segments of our economy and promises to continue to see growth well into the future. In order to be competitive, businesses must continue to hire well-trained professionals not only to produce high quality products for the present, but also to plan creative scientific and engineering advances for the future. In addition to all the business and communication jobs that may first come to mind, people with degrees in computer science are working on problems from almost all spectrums of life, example on journalism world, online traffic, earthquake detector, medical world about how the human brain works by modeling brain activation patterns with emphasis on helping people impacted by autism or disorders like paranoid schizophrenia, security and law enforcement.

Tugas Alpro. Ringkasan "Exchanging the values of two variables"

In this chapter, we will learn how to exchange values of two variable on a fundamental algorithms.
Lets begin the summary!

Problem

  •  Given two variables a and b, exchange the values assigned to them.

Algorithm development

Consider that the variables a and b are assigned values as outlined below. That is:
Starting Configuration