Soldato
scenario "Paula has decided to start offering quantity discounts for software. Paula wants to modify the program to handle quantity discounts. Now if some one buys 10 or more softwre of same title, Paula gives that customer 30% discount. A total of 7-9 results in 10% discount, and a total of 4-6 results in a 5% discount. A total of less than 4 results in no discount."
current program only only calculates V.A.T
I need help working out a code for the discount
I'm using Netbeans
thanks in advance
current program only only calculates V.A.T
Code:
import javax.swing.JOptionPane;
import javax.swing.JTextArea;
public class salesperson {
public static void main (String [] args)
{
String scode, stitle, sprice, sqty;
int code, title, price, qty;
double vatamt,total,subtotal;
final double VAT=.20;//VAT is set as a constant.
JTextArea message= new JTextArea();
JOptionPane.showMessageDialog(null, "Enter a new purchase to Proccess");
// input- ask the users to input datas.
scode=JOptionPane.showInputDialog("Please enter the code");
stitle=JOptionPane.showInputDialog("Please enter the title");
sprice=JOptionPane.showInputDialog("Please enter the price");
sqty=JOptionPane.showInputDialog ("Please enter the quattity");
//process
// convert the inputed datas to integers.
price=Integer.parseInt(sprice);
qty=Integer.parseInt(sqty);
// calculation.
subtotal= price*qty;
vatamt=subtotal*VAT;
total= subtotal+vatamt;
// rather than do a simply output like that...
//output the datas.
//System.out.println("The code: " + scode);
//System.out.println("The Title: " + stitle);
//System.out.println("The Price £: " + price);
//System.out.println("The Quantity: " + qty);
//System.out.println("The Subtotal £: " + subtotal);
//System.out.println("The VAT amount £: " + vatamt);
//System.out.println("The Final Total £: " + total);
//I do create a effecient output as pop window.
String output2 = "The Code: " + scode + "\nTitle: " + stitle +
"\nThe price: " + price + "\nQuantity: " + qty +
"\nThe Subtotal: " + subtotal + "\nThe VAT amount: " +
vatamt + "\nThe Final Total: " + total;
message.setText(output2);
JOptionPane.showMessageDialog(null, message);
//<editor-fold defaultstate="collapsed" desc="comment">
}
//</editor-fold>
I need help working out a code for the discount
I'm using Netbeans
thanks in advance
Last edited: