Results 1 to 4 of 4
  1. #1
    MyztikGecko is offline Member
    Join Date
    Aug 2015
    Posts
    8
    Rep Power
    0

    Default Very new to Java and Programming Altogether

    Hello all,

    I am extremely new to Java Programming and am taking an Intro to Java college class. I am not asking for anyone to do my assignments for me; however the book and classroom help is extremely vague. We are using jGRASP as the editor.

    I am running into an error and here is the code that has already been put in:

    public static void main(String[] arg)
    {
    //Pizza Party

    final int slicePizza = 10; //Number of slices per pizza
    final double pizzaCost = 10.50; //Cost per Pizza
    final double pizzaSliceCost = 1.25; //Cost per Slice
    final double drink = .90; //Cost per Drink
    final double tax = .095; //Tax of 9.5%

    double attendees;
    attendees = 108; //Number of attendees
    int slicePerPerson, drinkPerPerson;
    slicePerPerson = 4;
    drinkPerPerson = 2;

    double wholePizza = (attendees % 4);
    double pizzaSlice =

    System.out.print("The number attending is ");
    System.out.println(attendees);

    System.out.print("the number of whole pizzas required is ");
    System.out.println(wholePizza);

    System.out.print("The number of extra pieces is ");
    System.out.println(pizzaSlice);


    }
    }

    here is the error I am receiving:

    BockenstedtPass3.java:23: error: incompatible types
    System.out.print("The number attending is ");
    ^
    required: double
    found: void
    1 error

    Could someone point me in the right direction as to were to get assistance.


    Thank you.

  2. #2
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    6,226
    Rep Power
    14

    Default Re: Very new to Java and Programming Altogether

    First, please place your code betwee code tags. Read about them here --> BB Code List - Java Programming Forum - Learn Java Programming

    The problem has to do statement preceding your print statement. You are trying to assign the value returned by print to
    pizzaSlice. But print doesn't return anything so its not a legal statement.

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  3. #3
    Join Date
    Aug 2015
    Location
    Northern California
    Posts
    31
    Rep Power
    0

    Default Re: Very new to Java and Programming Altogether

    I think you meant to use a scanner but you forgot to add that line of code.

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    20,003
    Rep Power
    33

    Default Re: Very new to Java and Programming Altogether

    Note: These two lines:
    Java Code:
    System.out.print("The number of extra pieces is ");
    System.out.println(pizzaSlice);
    can be combined into one line:
    Java Code:
    System.out.println("The number of extra pieces is " + pizzaSlice);
    If you don't understand my response, don't ignore it, ask a question.

Similar Threads

  1. Replies: 3
    Last Post: 05-24-2014, 08:26 PM
  2. Replies: 1
    Last Post: 04-20-2013, 09:16 PM
  3. Replies: 1
    Last Post: 04-20-2013, 09:15 PM
  4. android programming vs game programming using java
    By vgoel38 in forum Forum Lobby
    Replies: 2
    Last Post: 09-08-2012, 12:11 AM

Posting Permissions

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