Advertisement
Telor_Goreng0

Nomor3

Mar 28th, 2021
26
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. import java.util.Scanner;
  2. public class nomor3 {
  3. public static void main (String[]args){
  4. Scanner in = new Scanner(System.in);
  5. int a,b;
  6. float all,x,r;
  7. System.out.print("Banyaknya Data :");
  8. b = in.nextInt();
  9. all = 0;
  10. a = 1;
  11. while (a <=b){
  12. System.out.println("Data Ke "+a+" :");
  13. x = in.nextFloat();
  14. all +=x;
  15. a++;
  16. }
  17. r = all/b;
  18. System.out.println("rata-rata : "+r);
  19. System.out.println("jumlah : "+all);
  20. }
  21. }
  22.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement