Results 1 to 5 of 5
  1. #1
    megironi is offline Member
    Join Date
    Feb 2009
    Posts
    4
    Rep Power
    0

    Default need help for a project

    I'm doing a project for school, and am just starting out. Really I don't know what I'm doing, I pretty much have to teach myself. Here's what I got so far, please help me if you can. To me it's like attempting to read a foreign language.


    import java.util.Scanner;
    import java.text.DecimalFormat;
    public class assignment2.java
    {
    final static double BOX_OF_APPLES = 14.00;
    final static double BOX_OF_PEACHES = 16.00;
    final static double BOX_OF_ORANGES = 18.00;
    final static double TAX = 0.10;
    public static void main(String[] args)
    {
    DecimalFormat money = new DecimalFormat("$0.00");
    Scanner in = new Scanner(System.in);
    System.out.print("How many boxes of apples do you want? ");
    System.out.print("How many boxes of peaches do you want? ");
    System.out.print("How many boxes of oranges do you want? ");
    double subTotal = in.nextInt() * BOX_OF_APPLES;
    double subTotal = in.nextInt() * BOX_OF_PEACHES;
    double subTotal = in.nextInt() * BOX_OF_ORANGES;
    double taxCost = subTotal * TAX;
    double total = subTotal + taxCost;
    System.out.println("Cost of food:148.00 " + money.format(subTotal));
    System.out.println("Tax:14.80 " + money.format(taxCost));
    System.out.println("Total:162.80 " + money.format(total));
    }
    }


    here was my assignment.
    The Lone Oak High School Marching Band is raising funds by selling fruit. In order to simplify processing of orders, only three types of packages of fruit are being sold. They are

    Box of Apples at a cost of $14.00
    Box of Peaches at a cost of $16.00
    Box of Oranges at a cost of $18.00

    There is a 10.00% tax on the total order amount. Write a Java program that reads the number of each type package on an order and computes the cost for the packages of each type ordered. Total the order, calculate the tax on the order, and the total including the tax. Print all items read and all items calculated with appropriate labels.

    Example:

    Boxes of Apples: 2
    Boxes of Peaches: 3
    Boxes of Oranges: 4

    Total cost of the fruit: 148.00
    Tax: 14.80
    Total Amount Due: 162.80
    Note: the red is user inputted information (2, 3, 4)

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

    Default

    You need to ask a specific question to get specific help since this is really what we're best at here. If the question is "I have no clue" then often the best answer is: have a talk with your teacher. Best of luck.

  3. #3
    toadaly is offline Senior Member
    Join Date
    Jan 2009
    Posts
    671
    Rep Power
    6

    Default

    It isn't going to compile, because you declared 'subTotal' 3 times in the same scope. What you want is something like...

    Java Code:
    double subTotal = 0;
    subTotal +=  in.nextInt() * BOX_OF_APPLES;
    subTotal += ...

  4. #4
    megironi is offline Member
    Join Date
    Feb 2009
    Posts
    4
    Rep Power
    0

    Default

    Can anyone tell me whats wrong with the line,

    public static void main(String[] args)

    Every time I build file, it has errors on that line that say,
    ; expected, .class' expected, and illegal start of operation. however, when I looked at an example and I can't figure out whats different.

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

    Default Don't need the extention...

    Your class definition is wrong....
    Java Code:
    public class assignment2[B][COLOR="Red"].java[/COLOR][/B]
    Get rid of the ".java"

    Luck,
    CJSL
    Chris S.
    Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.

Similar Threads

  1. open existing project project ..
    By itaipee in forum Eclipse
    Replies: 1
    Last Post: 12-28-2008, 08:12 PM
  2. Could anyone help with project?
    By billdara in forum New To Java
    Replies: 1
    Last Post: 03-12-2008, 05:05 PM
  3. First Project Need Big Help
    By earl in forum New To Java
    Replies: 1
    Last Post: 01-18-2008, 06:12 PM

Posting Permissions

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