vendredi 4 novembre 2016

Java program not working (new to java) [on hold]

Hi I started to learn Java and decided to participate in this online where we had to do a coding that I don't understand can someone help...

here's what you have to do: - The cost of calls is as follows: -For the first 200 call minutes: 20 cents per minute -For the next 100 minutes: 15 cents per minute -Over 300 minutes: 10 cents per minute - A discount is offered by the call time: -5% discount is granted if a quarter of the calls were made after 18 hours. -10% discount is granted if the third call was made after 18 hours. -15% discount is granted if half or more of the calls was made after 18 hours. - A 15% tax is applicable: o Only if the total cost exceeds $ 100 after rebates. Your program should ask the client code, the number of minutes of calls made before six hours and the number of minutes of calls made after eighteen hours and then displayed in a single dialog box, invoice containing all of the following, each in a line and well identified, specifying the unit when appropriate (%, $, minutes, ... ..) 1. The client code. 2. The total call minutes made by the customer. 3. The cost before the discount. 4. The percentage discount applied and the amount of the rebate. 5. The cost after the rebate. 6. The percentage of tax applied and the amount of the tax. 7. Final cost.

Your program must then ask if we wish to treat another client: - If the answer is yes, repeat the same process for another client - If not, it must display the following statistics (in a single dialog box): o The total number of clients treated o Total time of call minutes made by all customers. o The number of customers who were entitled to a discount

import javax.swing.JOptionPane ;

public class test {

    public static void main(String[] args) {


        int DISCOUNT1 = 0.05 , DISCOUNT2 = 0.1 , DISCOUNT3 = 0.15;
        int appel1, appel2;
        final double TAXE = 0.15 ;
        double costDiscount, costafDiscount, nbrClient, nmbreClient, montDiscount, priceFinal, callTotal ;
        String codeClient ;


        codeClient = JOptionPane.showInputDialog("Enter your client code :");
        Appel1 = JOptionPane.showInputDialog("Entrer your call before 6pm:");
        Appel2 = JOptionPane.showInputDialog("Entrer your calls after 6pm:");


        callTotal= call1+call2;
        // calcul du rabais
        if callTotal < 200 )
            costDiscount  = 0.20 * callTotal 
        else
            if callTotal > 300
                 costDiscount = 200 * 0.2 + 100 * 0.15 + (callTotal -300)* 0.1 

        else 
            costDiscount = 200 * 0.2 + (callTotal -200) * 0.15; 

        if appel2 >= callTotal / 2
                costafDiscount = (costDiscount * DISCOUNT3) - DISCOUNT3;


        else
            if Appel2 >= callTotal / 3
                costafDiscount = (costDiscount * DISCOUNT2) – DISCOUNT2
        else
            if Appel2 >= callTotal / 4
                costafDiscount = (costDiscount * DISCOUNT1) – DISCOUNT1

        if costafDiscount>= 100
    (costafDiscount*.015)+costafDiscount



        JOptionPane.showMessageDialog(null,

                    "Total calls: " + appelTotal +
                    "\nLe montant du rabais est " + rabais +
                    "\nLe coût net est " + coutNet);

}

}

Aucun commentaire:

Enregistrer un commentaire