Results 1 to 7 of 7

Thread: help please

  1. #1
    dysfunktional is offline Member
    Join Date
    Apr 2009
    Posts
    4
    Rep Power
    0

    Default help please

    i have a small program im working on for school could some one please help me and tell me were im goin wrong??


    import java.util.*;
    public class Assignment2

    {
    public static void main (String [] args)
    {
    Scanner input = new Scanner (System.in);
    //variables

    double product1 = 2.98;
    double product2 = 4.50;
    double product3 = 9.98;
    double product4 = 4.49;
    double product5 = 6.87;
    double totalproduct1;
    double totalproduct2;
    double totalproduct3;
    double totalproduct4;
    double totalproduct5;
    double total;
    char answer;
    int productCount;
    int quanityproduct1;
    int quanityproduct2;
    int quanityproduct3;
    int quanityproduct4;
    int quanityproduct5;



    // create loop

    productCount = 0;

    while (productCount < 6)
    {

    System.out.println("enter quantity for product1");
    quanityproduct1 = Console.readInt();

    System.out.println("enter quantity for product 2");
    quanityproduct2 = Console.readInt();

    System.out.println("enter quantity for product 3");
    quanityproduct3 = Console.readInt();

    System.out.println("enter quantity for product 4");
    quanityproduct4 = Console.readInt();

    System.out.println("enter quanity for product 5");
    quanityproduct5 = Console.readInt();

    productCount = productCount + 1;}

    //calculate total

    totalproduct1 = quanityproduct1 * product1;
    totalproduct1 = quanityproduct2 * product2;
    totalproduct1 = quanityproduct3 * product3;
    totalproduct1 = quanityproduct4 * product4;
    totalproduct1 = quanityproduct5 * product5;


    total = totalproduct1 + totalproduct2 + totalproduct3 + totalproduct4 + totalproduct5;

    System.out.println("total for all products is " + total);
    }
    }


    im getting errors at all the "quanityproduct1 = Console.readInt();" the error is "cnnot find symbol". I dont know wot it is as far as i can tell the code should work,iv been told i could use arrays but im still very new and not quite that far,anyway any help would be great

  2. #2
    emceenugget is offline Senior Member
    Join Date
    Sep 2008
    Posts
    564
    Rep Power
    12

    Default

    you should post the exact errors you get from the java if you want insight on them.

  3. #3
    logicbug's Avatar
    logicbug is offline Member
    Join Date
    Jan 2009
    Location
    The Great White North, eh?
    Posts
    76
    Rep Power
    0

    Default

    You defined your scanner as input, not Console.

    Try using input.readInt();

  4. #4
    dysfunktional is offline Member
    Join Date
    Apr 2009
    Posts
    4
    Rep Power
    0

    Default

    still get them same errors,

  5. #5
    markw8500's Avatar
    markw8500 is offline Senior Member
    Join Date
    Jul 2008
    Location
    Pennsylvania, USA
    Posts
    136
    Rep Power
    0

    Default

    You also have to initialize your quantityproducts... And make sure that your scanner is input.nextInt(),

    Also please post your errors...
    Who Cares... As Long As It Works...

  6. #6
    logicbug's Avatar
    logicbug is offline Member
    Join Date
    Jan 2009
    Location
    The Great White North, eh?
    Posts
    76
    Rep Power
    0

    Default

    Quote Originally Posted by markw8500 View Post
    make sure that your scanner is input.nextInt(),

    Also please post your errors...
    doh, I should have cought that.

  7. #7
    conv_bay is offline Member
    Join Date
    Apr 2009
    Posts
    15
    Rep Power
    0

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •