Results 1 to 6 of 6
  1. #1
    justin8790 is offline Member
    Join Date
    Mar 2009
    Posts
    1
    Rep Power
    0

    Default school project help

    I'm currently taking java in college and was give a project in which i edit the code and make it functional. Ive been messing with this code for hours now and its not making any sense why it wont compile.This is the part of the code that is giving me the problem compiling:
    if(inches=10)
    {
    {
    order.setSize(10);
    order.setCost(-2);
    }
    else if (inches=12)
    {
    order.setSize(12);
    order.setCost(0);
    }
    else if (inches=14)
    {
    order.setSize(14);
    order.setCost(2);
    }
    else if (inches=16)
    {
    order.setSize(16);
    order.setCost(4);
    }
    else
    {
    System.out.println("Sorry that was not one of the choices so a 12 inch pizza will be made.");
    order.setSize(12);
    order.setCost(0);
    }
    }
    Now i've tryed all different things to get this to work but it just keeps giving me errors such as incompatible types and non matching if else statements. Anyone know whats happening?

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    1 issue: what goes in if condition statements, = or == ?

    Also, when posting code here, please use code tags so that your code will retain its formatting and thus will be readable -- after all, your goal is to get as many people to read your post and understand your code as possible, right?

    To do this, highlight your pasted code (please be sure that it is already formatted when you paste it into the forum; the code tags don't magically format unformatted code) and then press the code button, and your code will have tags.

    Another way to do this is to manually place the tags into your code by placing the tag [code] above your pasted code and the tag [/code] below your pasted code like so:

    Java Code:
    [code]
      // your code goes here
      // notice how the top and bottom tags are different
    [/code]

  3. #3
    Aseem is offline Senior Member
    Join Date
    Mar 2009
    Location
    USA
    Posts
    127
    Rep Power
    0

    Default

    if(inches==10)

    {
    order.setSize(10);
    order.setCost(-2);
    }
    else if (inches==12)
    {
    order.setSize(12);
    order.setCost(0);
    }
    else if (inches==14)
    {
    order.setSize(14);
    order.setCost(2);
    }
    else if (inches==16)
    {
    order.setSize(16);
    order.setCost(4);
    }
    else
    {
    System.out.println("Sorry that was not one of the choices so a 12 inch pizza will be made.");
    order.setSize(12);
    order.setCost(0);
    }

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    And we are all impressed with your ability to do someone else's basic homework problem.

  5. #5
    CJSLMAN's Avatar
    CJSLMAN is offline Moderator
    Join Date
    Oct 2008
    Location
    Mexico
    Posts
    1,159
    Rep Power
    7

    Default Please don't post complete solutions

    Aseem... it's not a good idea to give complete solutions to the OPs... too much temptation for the OP to do a cut & paste & froget... no learning involved. You can help with code snippets, pseudo code, hints, explanations, links, etc.

    CJSL
    Last edited by CJSLMAN; 03-21-2009 at 10:27 PM. Reason: typo
    Chris S.
    Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.

  6. #6
    carderne is offline Senior Member
    Join Date
    Nov 2007
    Posts
    160
    Rep Power
    7

Similar Threads

  1. Reord management for a school
    By 435.mahesh in forum Advanced Java
    Replies: 4
    Last Post: 03-22-2009, 02:59 PM
  2. Taking Java In School Need Help
    By xEuPhOrIcSx in forum New To Java
    Replies: 7
    Last Post: 02-04-2008, 08:02 AM
  3. Replies: 2
    Last Post: 01-07-2008, 07:45 PM
  4. Beginner Needs Help w/ Program for School
    By badness in forum New To Java
    Replies: 2
    Last Post: 11-24-2007, 07:51 PM
  5. Please help... assignment for school
    By confused2000 in forum New To Java
    Replies: 3
    Last Post: 11-12-2007, 08:12 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
  •