Sabtu, 08 Juni 2013

PROGRAM VEKTOR DENGAN BILANGAN RANDOM


PROGRAM VEKTOR DENGAN BILANGAN RANDOM
import java.io.*;
class Tugas_Yogipratama
{
public static void main (String [] args) throws Exception
{
BufferedReader input = new BufferedReader (new InputStreamReader(System.in));

double []v1 = new double [10];
double []v2 = new double [10];
double[] dot = new double[10];
double kali = 0;

System.out.print("\nMasukkan Jumlah Elemen Vektor = ");
int n=Integer.parseInt(input.readLine());

System.out.println("vektor 1");
for(int i=0;i<n;i++)
{
System.out.print("elemen [1,"+i+"]= ");
v1[i]=Integer.parseInt(input.readLine());
}
System.out.println("\nvektor 2");
for (int i=0;i<n;i++)
{
System.out.println("elemen [1,"+i+"]= " + Math.random());
v2[i]=Math.random();
}
System.out.print("\npenjumlahan vektor : ");

for (int i=0; i<n; i++)
            {
            dot[i] = v1[i]*v2[i];
            kali = kali+dot[i];
            }
            System.out.println(kali);
            }
        }

Tidak ada komentar:

Posting Komentar