for Döngüsü
package javaapplication12;
import javax.swing.JOptionPane;
public class Main {
public static void main(String[] args) {
int Azalan=Integer.valueOf(JOptionPane.showInputDialog("Sayi giriniz"));
for(int Artan=Azalan; Azalan>0; Azalan--){
System.out.println(Azalan);
System.out.println(++Artan);
}
}
}
import javax.swing.JOptionPane;
public class Main {
public static void main(String[] args) {
int Azalan=Integer.valueOf(JOptionPane.showInputDialog("Sayi giriniz"));
for(int Artan=Azalan; Azalan>0; Azalan--){
System.out.println(Azalan);
System.out.println(++Artan);
}
}
}
package javaapplication14;
import javax.swing.JOptionPane;
public class Main {
public static void main(String[] args) {
int Baslangic=Integer.valueOf(JOptionPane.showInputDialog("Sayi giriniz"));
String Mesaj="";
for( ; Baslangic>0; Baslangic--){
//if(Baslangic%2!=0) {//Teksayilar
if(Baslangic%2==0) { //Cift Sayilar
Mesaj+=Baslangic+"n";
}
}
JOptionPane.showMessageDialog(null, Mesaj);
}
}
import javax.swing.JOptionPane;
public class Main {
public static void main(String[] args) {
int Baslangic=Integer.valueOf(JOptionPane.showInputDialog("Sayi giriniz"));
String Mesaj="";
for( ; Baslangic>0; Baslangic--){
//if(Baslangic%2!=0) {//Teksayilar
if(Baslangic%2==0) { //Cift Sayilar
Mesaj+=Baslangic+"n";
}
}
JOptionPane.showMessageDialog(null, Mesaj);
}
}
package javaapplication15;
import javax.swing.JOptionPane;
public class Main {
public static void main(String[] args) {
int Toplam=0;
int Sayi1=Integer.valueOf(JOptionPane.showInputDialog("Sayi1 girin"));
int Sayi2=Integer.valueOf(JOptionPane.showInputDialog("Sayi2 girin"));
Sayi1++;
for(; Sayi1<Sayi2; Sayi1++){
Toplam+=Sayi1;
}
JOptionPane.showMessageDialog(null, Toplam);
}
}
import javax.swing.JOptionPane;
public class Main {
public static void main(String[] args) {
int Toplam=0;
int Sayi1=Integer.valueOf(JOptionPane.showInputDialog("Sayi1 girin"));
int Sayi2=Integer.valueOf(JOptionPane.showInputDialog("Sayi2 girin"));
Sayi1++;
for(; Sayi1<Sayi2; Sayi1++){
Toplam+=Sayi1;
}
JOptionPane.showMessageDialog(null, Toplam);
}
}
Yorumunuzu Ekleyin