Tips 23 : Jawapan latihan formatif no 3 ms 108

Berikut adalah jawapan latihan formatif 1.4 m/s 108

import java.util.Scanner;
public class NomborGenap{
public static void main(String [ ] args){
Scanner input = new Scanner(System.in);
System.out.println(“Masukkan nombor mula “);
int noMula = input.nextInt();
System.out.println(“Masukkan nombor akhir “);
int noTamat = input.nextInt();
System.out.println(“Senarai nombor genap antara ” + noMula + ” dan ” + noTamat + ” ialah ” );

for(int no=noMula ; no<=noTamat ; no ++){
if (no % 2 == 0)
System.out.println(no);
}
}
}

This entry was posted in Berita Utama. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *