Advertisement
aznGiLL

3aaaaaaaaaaaaaaa

Oct 28th, 2011
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.71 KB | None | 0 0
  1. /**
  2.  * @(#)oppgave3a.java
  3.  *
  4.  *
  5.  * @Anders Gill
  6.  * @version 1.00 2011/10/23
  7.  */
  8.  
  9. import java.util.Scanner; // Scanner
  10.  
  11. public class oppgave3a { // name of the class
  12.  
  13.     public static void main(String[] args) {
  14.  
  15.         getSum(); // calls the method getSum
  16.  
  17.     }
  18.  
  19.     public static void getSum() { // openbracket for the method getSum
  20.         Scanner console = new Scanner(System.in); // decleration of scanner
  21.  
  22.         System.out.print("Oppgi øvre grense: "); // requests integer tall
  23.         int tall = console.nextInt();
  24.         System.out.println("Summen opp til og med " + tall + " er " + (1 + tall)*tall/2); // expression for the problemsolving (1 + n)*(n/2)
  25.     } // endingbracket for the method getSum
  26.  
  27. }
  28.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement