Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Prov;
- import java.util.Scanner;
- public class Prov_Repetition_uppgift4 {
- public static void main(String[] args) {
- //deklationer
- double n;
- Scanner input = new Scanner(System.in);
- //inmatningar
- System.out.print("Skriv ett heltal: ");
- n = input.nextInt();
- //beräkningar
- double total = 0;
- for(double i = 1; i <= n; i++) {
- total = (total) + (i*i);
- //utmatningar
- System.out.println("Värde på n: " + n);
- System.out.println("Summan är: " + total/n);
- }
- input.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement