7 Mart 2014 Cuma

JAVA Örnekler-2

//0'DAN 10'A KADAR OLAN SAYILARIN TOPLAMI

public class PROGRAM6 {
public static void main (String Arg[])
{ 
 int t=0;
 int s;
 for(s=0;s<=10;s++)
 t=t+s;
 System.out.println(t);
}}

//0 ILE 100 ARASINDAKI CIFT SAYILAR TOPLAMI

public class PROGRAM7 {
public static void main (String Arg[])
{ 
int s;
int t=0;
for(s=0;s<101;s++)
{
if(s%2==0)
{
t=t+s;
}}
System.out.println(t);
}}

//KLAVYEDEN GIRILEN SAYININ FAKTORIYELINI HESAPLAMA

import java.util.Scanner;
public class PROGRAM8 {
private static Scanner oku;
public static void main (String Arg[])
{ 

 int s;
 int f=1;
 oku = new Scanner (System.in);
 System.out.println("BIR SAYI GIRINIZ:"); 
 s=oku.nextInt();

 for(int i=2; i<-s; i++) 
 {
  f=i*f;
 }
  
  System.out.println(s+" SAYISININ FAKTORIYELI = "+f);
 }}

//GIRILEN SAYI KADAR EKRANA BOZOK MYO YAZDIRMA
import java.util.Scanner;
public class PROGRAM9 {
 private static Scanner oku;
 public static void main (String Arg[])
 {
  oku = new Scanner(System.in);
  System.out.println("BIR SAYI GIRINIZ:");
  int m;
  int s;
  m=oku.nextInt();
  System.out.println();
  for (s=0;s<m;s++)
  {
   System.out.println("BOZOK MYO");
  }
}}


//N ADET SAYININ KARELERI TOPLAMI
import java.util.Scanner;
public class PROGRAM10 {
private static Scanner oku;

public static void main(String[] args) 
{
oku = new Scanner(System.in);
int t=0;
int k=0;
int a;

System.out.println("BIR SAYI GIRINIZ:");
a=oku.nextInt();

  for (int i = 1;i<=a;i++)
 {
  k=i*i;
  t=t+k;
  System.out.println(i+"'IN  KARESI = "+k);
 }
    System.out.println("SAYILARIN KARELERI TOPLAMI = "+t);
}}

2 yorum:

Copyright 2013-2017 | İbrahim BAYRAKTAR /dev/null Web Günlüğü