creating bill

code in which the creation of a bill through java netbeans is easy done, I hope to provide to those who want to start programming or those who are studying and let them work something haha

Scanner first library is brought after capturing user data with String variables take a method to calculate vat where the operation is performed to calculate the total is multiplied product cost with the amount of product is made, then the VAT is which is the total multiplied by 16 and divided by 100 after taxes plus the total adds a System.out.println and the total sum is displayed; method also creates one invoice within this there one System.out.println showing all data with the user's digit plus the VAT invoice.

EXCEPTIONS:
when the user enters the number one option while typing which is created if the user what digit is less than 1, would send one System.out.println telling you to enter valid values ​​as if this is no exception would put when multiplied by quantity daria cost 0 and 0 serious bill and the same operation with unit cost.


public class main {
 static String direc,nom,tel;
       static int cantidad,id, habitaciones;
       static double costo;
        static double iva, total;
        static double tot;
        static String personas;
 
    public static void main(String[] args) {
   
       Scanner sc= new Scanner (System.in);
         System.out.println ("Enter name:");
        nom=sc.next();
         System.out.println ("address type in:");
        direc=sc.next();
          System.out.println ("phone type in:");
        tel=sc.next();
          System.out.println ("type in identification:");
        id=sc.nextInt();  
       System.out.println ("Enter number");
        cantidad=sc.nextInt();
        while(cantidad<1){
            System.out.println ("type in valid values​​");
            cantidad=sc.nextInt();
        }
         System.out.println ("type in unit cost");
        costo=sc.nextInt();
     
        while(costo<1){
            System.out.println ("type in valid values​​");
            costo=sc.nextInt();
        }
     bill ();
        calcularIva ();
    }

    public static void bill(){
   

 
    System.out.println("your bill is " + "\n" +" name"  + nom + "\n" + "adrress " + direc + "\n" +
            "phone " + tel + "\n" + "idenfication " + id + "\n" + "unit cost "+ costo +"\n" );
 }
    public static void calcularIva(){
         total = costo*cantidad;
        iva=(total*16)/100;
        tot=total+iva;
        System.out.println("total cost" + tot);
    }
}

follow me :D



Comentarios

Entradas más populares de este blog

como crear factura java

hora militar

Clase PlaceHolder para campos de texto en Java