Results 1 to 5 of 5
Thread: need help for a project
- 02-07-2009, 10:57 AM #1
Member
- Join Date
- Feb 2009
- Posts
- 4
- Rep Power
- 0
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)
-
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.
- 02-07-2009, 07:07 PM #3
Senior Member
- Join Date
- Jan 2009
- Posts
- 671
- Rep Power
- 5
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 += ...
- 02-07-2009, 08:22 PM #4
Member
- Join Date
- Feb 2009
- Posts
- 4
- Rep Power
- 0
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.
- 02-07-2009, 08:28 PM #5
Similar Threads
-
open existing project project ..
By itaipee in forum EclipseReplies: 1Last Post: 12-28-2008, 08:12 PM -
Could anyone help with project?
By billdara in forum New To JavaReplies: 1Last Post: 03-12-2008, 05:05 PM -
First Project Need Big Help
By earl in forum New To JavaReplies: 1Last Post: 01-18-2008, 06:12 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks