“ SOFTWARE ENGINEERING ”
DOSEN : Dr. Ir. Gunadi Nurcahyo, M.Sc
D
i
s
u
s
u
n
Oleh :
Flowgrap
2,3
6
4,5
8 7
10
11
Pada contoh Gambar 2 di atas, flowchart dikonversi menjadi sebuah flowgraph. Semua
notasi pada flowchart akan diubah menjadi notasi lingkaran/edge pada flow graph dengan
menggunakan panduan berikut:
Notasi yang berurutan baik berupa proses (persegi panjang) maupun seleksi
(diamond) dapat digabungkan menjadi satu node. Contoh:
- proses 2 dan decision 3 pada flowchart digabungkan menjadi satu node 1,2 o
proses 4 dan 5, digabungkan menjadi node 4,5
Notasi awal, digabungkan dengan notasi pertama menjadi satu node. Contoh:
- start node dan decision 1 pada flowchart menjadi node 1 pada flow graph.
Sebuah edge harus selalu dihubungkan dengan sebuah node, sehingga bentuk
penggabungan dari beberapa edge dapat ditambahkan sebuah node sebelum
menuju statement berikutnya meskipun node tersebut tidak memiliki sebuah
statement khusus. Contoh:
-masing-masing simpul pada nomor 9 dan 10 dibuah menjadi sebuah node; node
9 dan node 10 pada flow graph.
Final node pada flowchart diubah menjadi sebuah node pada flow graph seperti
Here is some java code that reads in daily data for rainfall, average windspeed and
hours of sun for a number of days and prints out summary statistics. Use a
program flow graph to show the paths through the program and to calculate the
cyclomatic complexity. This should determine the number of independent paths.
Now make up some data to test each path.
import java.io.*;
import java.text.*;
public class Weather{
}//for j
System.out.println();
}//for i
//menu
int choice=0;
while (choice == 0)
{ System.out.println("Stats for");
System.out.println("\t1. Rain");
System.out.println("\t2. Wind");
System.out.println("\t3. Sun\n");
System.out.println("\tChoice: ");
try{
choice = Integer.parseInt(keyb.readLine());
}
//reports
int total = 0;
switch (choice)
{ case 1: //average rain
for(i=0; i<NumberOfDays; i++)
{ total = total + wData[i][0];
}//for i
System.out.println("\nAverage Rain = " + total/NumberOfDays);
break;
case 2: //average wind
for(i=0; i<NumberOfDays; i++)
{ total = total + wData[i][1];
}//for i
System.out.println("\nAverage WindSpeed = " +
total/NumberOfDays);
break;
case 3://average sun
for(i=0; i<NumberOfDays; i++)
{ total = total + wData[i][2];
}//for i
System.out.println("\nAverage Hours Sun = " +
total/NumberOfDays);
break;
default: choice = 0;
}//switch
}//while
System.out.println();
}//main
}//Weather
Flowgraph
import java.io.*;
import java.text.*;
public class Weather{
private static BufferedReader keyb = new BufferedReader(
new InputStreamReader(System.in));
public static void getWeatherStats(int NumberOfDays)
{ int i,j; 1
int wData[][] = new int[NumberOfDays][3]; //2-D array for the weather data
2 String wType[] = {"Rainfall", "WindSpeed", "Hours of Sun"}; //1-D array for
type of data
//read in the data
for(i=0; i<NumberOfDays; i++) 3
System.out.println();
}//for i 9
//menu
int choice=0;
1
while (choice == 0)
{ System.out.println("Stats for"); 1
System.out.println("\t1. Rain");
System.out.println("\t2. Wind");
System.out.println("\t3. Sun\n");
System.out.println("\tChoice: ");
1
try{
choice = Integer.parseInt(keyb.readLine());
}
//reports
int total = 0;
1 switch (choice)
1
{ case 1: //average rain
for(i=0; i<NumberOfDays; i++) 1
}//main 3
}//Weather 3
Independent Path
CC = (40-31)+2
=9+2
= 11
40 = Banyak Panah
31 = Banyak Bulatan
2 = Kententuan
1. 1,2,3,4,5,6,7,3
2. 1,2,3,4,5,7,3
3. 1,2,3,4,5,6,7,3,8,2 /
1,2,3,4,5,7,3,8,2
4. 1,2,9,10,11,12,13,14,15,16,17,16
5. 1,2,9,10,11,12,13,14,15,20,21,20
6. 1,2,9,10,11,12,13,14,15,24,25,24
7. 1,2,9,10,11,12,14,15,16,17,16
8. 1,2,9,10,11,12,14,15,20,21,20
9. 1,2,9,10,11,12,14,15,24,25,24
10. 1,2,9,10,11,12,13,14,15,16,18,19,28,10 /
1,2,9,10,11,12,13,14,15,20,22,23,28,10 /
1,2,9,10,11,12,13,14,15,24,26,27,28,10 /
1,2,9,10,11,12,14,15,16,18,19,28,10 /
1,2,9,10,11,12,14,15,20,22,23,28,10 /
1,2,9,10,11,12,14,15,24,26,27,28,10
11. 1,2,9,10,29,30,31