Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: Help! im stuck!

  1. #1
    Junior Member
    Join Date
    Sep 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Help! im stuck!

    Lag et program som først leser inn to tall, a og b. Deretter skal programmet ved hjelp av en while-løkke
    summere alle heltallene som ligger mellom a og b (hverken a eller b skal taes med i summen), og skrive ut
    hva summen blir. Programmet kan ikke anta at det minste (eller største) tallet blir lest inn først

    So my Assignment is to make a program, that reads 2 numbers, A and B. This program are too use a while-loop, to plus the numbers between what ive selected for example: " 2 8 gives 3+4+5+6+7=25"
    this is how far i've come ->


    import java.util.Scanner;
    class HeltallsSummering {
    public static void main(String[] args) {
    int antallTall,antallLest; // Antall tall man hhv. skal og har lest inn
    int nesteTall, sum; // nestetall og summen av alle innleste tall så langt

    Scanner tastattur = new Scanner(System.in);
    System.out.print("Gi antall heltall som skal summeres: ");
    antallTall = tastatur.nextInt();
    tastatur.nextLine();

    antallLest = 0;
    Sum = 0;

    while (antallLest < antallTall) {
    System.out.printf("gi %d. tall [Heltall]: ", antallest+1);
    nesteTall = tastatur.nextInt();
    tastatur.nextLine();
    sum = sum + nesteTall;
    antallLest = antallLest + 1;
    }
    System.out.print("summen av d% heltall er %d%n", antallLest, sum);
    }
    }


    For some reason, i keep getting this error message-> File: C:\Users\Portapro\HeltallsSummering.java [line: 9]
    Error: tastatur cannot be resolved

    Please help any1?


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: Help! im stuck!

    Check spelling. tastatur != tastattur

  3. #3
    Junior Member
    Join Date
    Sep 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Help! im stuck!

    oh lol!
    oh well i found out that this wasnt the script i were suposed to write :/

  4. #4
    Junior Member
    Join Date
    Sep 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Help! im stuck!

    oh lol!
    oh well i found out that this wasnt the script i were suposed to write :/

Similar Threads

  1. Im stuck, please help
    By bigsmoke101 in forum Loops & Control Statements
    Replies: 3
    Last Post: April 12th, 2011, 04:34 PM
  2. PLEASE PLEASE I AM STUCK...
    By ThejavaBUM in forum Loops & Control Statements
    Replies: 2
    Last Post: April 5th, 2011, 10:16 PM
  3. Stuck again
    By Tate in forum What's Wrong With My Code?
    Replies: 2
    Last Post: November 28th, 2010, 11:22 AM
  4. Stuck help please!
    By mindlessn00b in forum What's Wrong With My Code?
    Replies: 4
    Last Post: October 5th, 2010, 05:31 PM
  5. I am stuck
    By hawkman4188 in forum What's Wrong With My Code?
    Replies: 5
    Last Post: June 29th, 2010, 12:46 AM