Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * @(#)oppgave3a.java
- *
- *
- * @Anders Gill
- * @version 1.00 2011/10/23
- */
- import java.util.Scanner; // Scanner
- public class oppgave3a { // name of the class
- public static void main(String[] args) {
- getSum(); // calls the method getSum
- }
- public static void getSum() { // openbracket for the method getSum
- Scanner console = new Scanner(System.in); // decleration of scanner
- System.out.print("Oppgi øvre grense: "); // requests integer tall
- int tall = console.nextInt();
- System.out.println("Summen opp til og med " + tall + " er " + (1 + tall)*tall/2); // expression for the problemsolving (1 + n)*(n/2)
- } // endingbracket for the method getSum
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement