0

Here is my main...

public class Yamaha {

/**
 * @param args the command line arguments
 */
public static void main(String[] args) {
    productoYamaha p1, p2;
    p1= new productoYamaha ();
    p2= new productoYamaha ('empacador',20.00);
    p1.imprimir();
    p2.imprimir();
    System.out.println("El total a pagar es"total_a_pagar);
    // TODO code application logic here
}

And here is the code i write

enter code here package yamaha;

/**
 *
 * @author Soria
 */
public class productoYamaha {
    double pProducto;
    String nProducto;

   public productoYamaha(){
       this.nProducto="";
       this.pProducto=0;
   }

   public productoYamaha (double pProducto, String nProducto){
       this.nProducto=nProducto;
       this.pProducto=pProducto;
   }
   public double gYamaha (int cantidad){
       double gcantidad;
       gcantidad= this.pProducto*cantidad;
       return gcantidad;
   }
   public void imprimir (){
       System.out.println("nombre del producto"+nProducto);
       System.out.println("precio del Producto"+pProducto);

   }
}

And i'm having this error

Exception in thread "main" java.lang.RuntimeException: Uncompilable source code - Erroneous ctor sym type: at yamaha.Yamaha.main(Yamaha.java:20) C:\Users\Erick_Soria\AppData\Local\NetBeans\Cache\8.2\executor-snippets\run.xml:53: Java returned: 1 BUILD FAILED (total time: 0 seconds)

What i'm doing wrong?

2
  • 2
    p2= new productoYamaha ('empacador',20.00); Two things: (1) the parameters seem to be backwards and (2) a String literal is declared using double quotes ("). Commented Oct 26, 2018 at 4:59
  • I'm having now this issue... Commented Oct 26, 2018 at 5:09

1 Answer 1

0

Your producttoYamaha constructer with arguments is

public productoYamaha (double pProducto, String nProducto)

.........

So you need to provide first argument as double and second as String and also String argument should be provided inside double quotes("empacador" ) instead single ('empacador ')

Also there is problem with print statement inside main which needs correction.

public static void main(String[] args) { 
productoYamaha p1, p2; 
p1= new productoYamaha ();
// first argument should be a double and second should be string 
p2= new productoYamaha (20.00, "empacador"); 
p1.imprimir();
p2.imprimir(); 
//concat two arguments with '+' inside print statements 
System.out.println("El total a pagar es" +total_a_pagar);
//      TODO code application logic here
 }
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.