I'm new to programming with Java
, and I do not know what similarities I have with C
, if someone can correct me the program I would appreciate it. The objective of the program is to calculate a supermarket bill. When I give run only the end of the program comes out with the message "the value of your invoice is: 0.0".
Whoever can answer my question please tell me where my error or errors are.
package punto.pkg3;
import java.util.Scanner;
public class Punto3 {
public static void main(String[] args) {
Scanner entrada=new Scanner (System.in);
double a=0;
double b=0;
double c=0;
double d=0;
double e=0;
double f=0;
double g=0;
while (a==1) {
System.out.println("hay mas productos?");
System.out.println("1=si, 2 =no");
a=entrada.nextDouble();
while (a!=1 | a!=2){
System.out.println("no es un valor valido, vuelva a digitar");
a=entrada.nextDouble();
}
System.out.println("digite el valor del producto");
b=entrada.nextDouble();
System.out.println("cuantas unidades llevo de este producto?");
c=entrada.nextDouble();
d=b*c;
e=d+(d*16/100);
if(e>=50000)
e=e-(e*5/100);
else
break;
f=f+e;
}
System.out.println("el valor de su factura es:" +f);
}
}