Results 1 to 3 of 3
Thread: JavaHelp (Discount Calculator)
- 02-24-2010, 05:04 AM #1
Member
- Join Date
- Feb 2010
- Posts
- 2
- Rep Power
- 0
JavaHelp (Discount Calculator)
I'm trying to create a class that stores the number of units sold and has a method that returns the total cost of the purchase.
It displays a small chart with the quantity and percent discount.
I cant figure this out, can anyone help?
below is the the code I have so far. :( :confused: :eek:
import java.util.Scanner;
public class salescommision
{
public static void main(String[] args)
{
double
total = 99, //The total price before the offered discount was supposed to be 99$
quantity,
discount = 0,
cost = (total-discount);
Scanner keyboard = new Scanner(System.in);
System.out.println("This program calculates the discounts "
+ "3 test scores.");
System.out.print("Enter quantity: ");
quantity = keyboard.nextDouble();
total = (total * discount);
System.out.println("The total is " + total);
// The goal is if between these number of quantities you will get a certain percent discount
if (total < 19)
System.out.println("20%");
else if (total < 49)
System.out.println("30%");
else if (total < 99)
System.out.println("40%");
else if (total < 100)
System.out.println("50%");
}
}Last edited by dcoi; 02-24-2010 at 05:07 AM. Reason: typo
- 02-24-2010, 08:11 AM #2
Senior Member
- Join Date
- Aug 2009
- Posts
- 2,388
- Rep Power
- 6
1.) Please use code tags when posting code.
2.) What happens when you attempt to compile/run your code and what did you expect instead?
- 02-24-2010, 10:32 PM #3
Member
- Join Date
- Feb 2010
- Posts
- 2
- Rep Power
- 0
:confused:The exact assignment is:
A company sells a package for 99$. Quantity discounts are given according to the current table.
Quantity Discount
10-19 20%
20-49 30%
50-99 40%
100 or More 50%
Design a class that stores the number of units sold and has a method that returns the total cost of the purchase.
My outcome is: (with 23 entered, but any # can be).
Enter quantity: 23
The total is 99.0
20%
I have to somehow make an if/else statement that calculates percentages and displays in the println? But I keep trying and failing, If you could help at all or lead me to a better direction I would really appreciate it.
Similar Threads
-
I need Sun Voucher for discount price.
By salma in forum Java CertificationReplies: 2Last Post: 01-09-2010, 01:48 AM -
Discount Java Certification Exam Vouchers
By mbrown36 in forum Reviews / AdvertisingReplies: 17Last Post: 12-15-2009, 06:10 PM -
need help with my calculator
By semoche in forum AWT / SwingReplies: 6Last Post: 12-04-2009, 10:16 PM -
Sun Java Exam Vouchers at 40% Discount! Validity-10th Nov
By sudeepa@whizlabs.com in forum Reviews / AdvertisingReplies: 1Last Post: 07-14-2009, 01:10 PM -
JavaHelp
By helloWorld564 in forum New To JavaReplies: 4Last Post: 02-16-2009, 11:34 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks