Advertisement
Guest User

fanelli

a guest
Nov 30th, 2015
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.47 KB | None | 0 0
  1. import java.util.Scanner;
  2.     public class quadrato {
  3.         public static void main (String args[]) {
  4.             int N;
  5.             int i;
  6.             int num;
  7.             int quad=0;
  8.    
  9.             Scanner kb=new Scanner (System.in);
  10.    
  11.             System.out.println ("Inserisci il numero N:");  //Chiedo il numero.
  12.             N=kb.nextInt();                            
  13.    
  14.             for (i=1;i<=N*2;i+=2) {
  15.                 quad=quad+i;
  16.             }
  17.             System.out.println(+N+ " al quadrato vale "+quad+ ".");
  18.         }
  19.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement