Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class punto2 {
- public static void main(String[] args) {
- Scanner num= new Scanner (System.in);
- int cont=0;
- int cont1=0;
- int a,b,S;
- int stotal=0;
- int sproducto=0;
- String select=null;
- String respuesta="s";
- while(respuesta=="s") {
- System.out.println("elija una opcion: \n +: suma \n -: resta \n *: multiplicacion \n /: division");
- select=num.nextLine();
- switch(select) {
- case "+":
- System.out.println("Ingrese un numero");
- a=num.nextInt();
- System.out.println("Ingrese un numero");
- b=num.nextInt();
- System.out.println("la suma es: "+(a+b) );
- int suma=a+b;
- stotal=stotal+suma;
- break;
- case "-":
- System.out.println("Ingrese un numero");
- a=num.nextInt();
- System.out.println("Ingrese un numero");
- b=num.nextInt();
- System.out.println("la resta es: "+(a-b) );
- break;
- case "*":
- System.out.println("Ingrese un numero");
- a=num.nextInt();
- System.out.println("Ingrese un numero");
- b=num.nextInt();
- System.out.println("la multiplicacion es: "+(a*b) );
- int producto= a*b;
- sproducto=sproducto+producto;
- cont1++;
- break;
- case "/":
- System.out.println("Ingrese un numero");
- a=num.nextInt();
- System.out.println("Ingrese un numero");
- b=num.nextInt();
- if (b==0) {
- System.out.println("no es posible realizar la division");
- cont++;
- break;
- }
- else {
- System.out.println("la division es: "+(a/b) );
- break;
- }
- }
- System.out.println("desea continuar? s/n");
- respuesta=num.nextLine();
- }
- System.out.println("total de suma acumlada: "+ stotal);
- System.out.println("hubo "+ cont+ " errores");
- System.out.println("promedio del producto: "+sproducto/cont1);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement