Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.tutorial;
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner userInput = new Scanner(System.in);
- int n;
- float angka, rata;
- float jumlah = 0f;
- System.out.println("\t Jumlah dan Rata Nilai \n");
- System.out.print("\n Masukkan Jumlah Data : ");
- n = userInput.nextInt();
- for (int i = 1; i <= n; i++) {
- System.out.print(" Data ke " + i + " : ");
- angka = userInput.nextFloat();
- jumlah += angka;
- }
- rata = jumlah / n;
- System.out.print("\n Jumlahnya : " + jumlah);
- System.out.print("\n Rata-ratanya : " + rata);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement