Results 1 to 9 of 9

Thread: help with code!

  1. #1
    Join Date
    Nov 2013
    Posts
    29
    Rep Power
    0

    Default help with code!

    i need to Write a Java program called that computes the cost of a house given its square foot area, cost per square foot and discount.
    The program needs to accept cost per square foot and square foot area as user inputs.
    The discount value should be a constant coded in the program.
    It should output the cost before discount and cost after discount to the screen with appropriate print statements including text and numbers.

    code



    // decrlations

    final double discount = 20.00;

    int Cost, squareFootArea;

    // user input

    Scanner cost = new Scanner (System.in);

    System.out.println("Please enter the desired cost");

    Cost = cost.nextInt();

    Scanner SFA = new Scanner (System.in);

    System.out.println("Please enter the desired Square foot");

    squareFootArea = SFA.nextInt();

    // final print outs

    System.out.println("The cost without the discount will be:" (Cost+squareFootArea));

    System.out.println("The cost with the discount will be:" (Cost+squareFootArea/discount));

    }

    }

    please let me no if its correct

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,949
    Rep Power
    19

    Default Re: help with code!

    Does it produce the correct result?

    Also, when posting code please wrap it in [code] tags [/code].
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  3. #3
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    3,900
    Rep Power
    5

    Default Re: help with code!

    I don't get the question indeed. Compile it, run it, see what it does. Then you can answer it yourself.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  4. #4
    Join Date
    Nov 2013
    Posts
    29
    Rep Power
    0

    Default Re: help with code!

    Quote Originally Posted by Tolls View Post
    Does it produce the correct result?

    Also, when posting code please wrap it in [code] tags [/code].
    the end results are below:

    Please enter the desired cost
    199
    Please enter the desired Square foot
    200
    The cost without the discount will be:399
    The cost with the discount will be:209.0


    I just want to know if i coded every step that was stated above my first message
    Last edited by shad0wblade890; 11-08-2013 at 06:18 PM.

  5. #5
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    3,526
    Rep Power
    5

    Default Re: help with code!

    I don't believe this works they way you intend. First, you need to decide if the discount is per square foot. So you have the cost per square foot and the discounted cost per square foot. Then the final cost is the price x no sq ft.

    Regards,
    Jim
    The Java™ Tutorial | SSCCE | Java Naming Conventions
    Poor planning our your part does not constitute an emergency on my part.

  6. #6
    Join Date
    Nov 2013
    Posts
    29
    Rep Power
    0

    Default Re: help with code!

    Quote Originally Posted by jim829 View Post
    I don't believe this works they way you intend. First, you need to decide if the discount is per square foot. So you have the cost per square foot and the discounted cost per square foot. Then the final cost is the price x no sq ft.

    Regards,
    Jim
    i dont think the discount is PSF or anything... and what you mean by the final cost is x? as stated it saays:

    The discount value should be a constant coded in the program.
    It should output the cost before discount and cost after discount to the screen with appropriate print statements including text and numbers.


    which i think i did
    Last edited by shad0wblade890; 11-08-2013 at 07:14 PM.

  7. #7
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    3,526
    Rep Power
    5

    Default Re: help with code!

    Having a discount coded as a constant just means something like:

    final int discount = 20;

    If the cost per square foot is p and the number of sq ft is n then then the total price without discount is n x p. Now the question is whether the
    discount is per square foot or simply subtracted from the total price.

    But you may interpret your assignment however you wish. I just gave you my opinion.

    Regards,
    Jim
    The Java™ Tutorial | SSCCE | Java Naming Conventions
    Poor planning our your part does not constitute an emergency on my part.

  8. #8
    Join Date
    Nov 2013
    Posts
    29
    Rep Power
    0

    Default Re: help with code!

    ok thx man! i think it just means sub from total ... what i wrote is every thing .... also the 2 end results should be * or +? theres 2 end print statements i need first w/o discount sec with discount

  9. #9
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    3,526
    Rep Power
    5

    Default Re: help with code!

    Use * for multiply. So n * p for total price. Then just subtract the discount if that is what the prof wants.

    Regards,
    Jim
    The Java™ Tutorial | SSCCE | Java Naming Conventions
    Poor planning our your part does not constitute an emergency on my part.

Similar Threads

  1. Replies: 1
    Last Post: 03-25-2012, 02:40 AM
  2. Replies: 16
    Last Post: 01-31-2012, 08:36 PM
  3. Replies: 3
    Last Post: 08-10-2011, 09:17 AM
  4. Replies: 0
    Last Post: 08-07-2011, 08:32 PM
  5. Replies: 0
    Last Post: 02-21-2011, 11:50 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
  •