Advertisement
RAUL-SUAREZ

Untitled

Aug 28th, 2021
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.81 KB | None | 0 0
  1. import java.util.Scanner;
  2. public class punto2 {
  3.  
  4. public static void main(String[] args) {
  5.  
  6. Scanner num= new Scanner (System.in);
  7. int cont=0;
  8. int cont1=0;
  9. int a,b,S;
  10. int stotal=0;
  11. int sproducto=0;
  12. String select=null;
  13. String respuesta="s";
  14. while(respuesta=="s") {
  15. System.out.println("elija una opcion: \n +: suma \n -: resta \n *: multiplicacion \n /: division");
  16. select=num.nextLine();
  17.  
  18. switch(select) {
  19. case "+":
  20. System.out.println("Ingrese un numero");
  21. a=num.nextInt();
  22. System.out.println("Ingrese un numero");
  23. b=num.nextInt();
  24.  
  25. System.out.println("la suma es: "+(a+b) );
  26. int suma=a+b;
  27. stotal=stotal+suma;
  28. break;
  29. case "-":
  30. System.out.println("Ingrese un numero");
  31. a=num.nextInt();
  32. System.out.println("Ingrese un numero");
  33. b=num.nextInt();
  34. System.out.println("la resta es: "+(a-b) );
  35. break;
  36. case "*":
  37. System.out.println("Ingrese un numero");
  38. a=num.nextInt();
  39. System.out.println("Ingrese un numero");
  40. b=num.nextInt();
  41. System.out.println("la multiplicacion es: "+(a*b) );
  42. int producto= a*b;
  43. sproducto=sproducto+producto;
  44. cont1++;
  45. break;
  46. case "/":
  47. System.out.println("Ingrese un numero");
  48. a=num.nextInt();
  49. System.out.println("Ingrese un numero");
  50. b=num.nextInt();
  51. if (b==0) {
  52. System.out.println("no es posible realizar la division");
  53. cont++;
  54. break;
  55. }
  56. else {
  57. System.out.println("la division es: "+(a/b) );
  58. break;
  59. }
  60. }
  61. System.out.println("desea continuar? s/n");
  62. respuesta=num.nextLine();
  63.  
  64. }
  65. System.out.println("total de suma acumlada: "+ stotal);
  66. System.out.println("hubo "+ cont+ " errores");
  67. System.out.println("promedio del producto: "+sproducto/cont1);
  68.  
  69. }
  70. }
  71.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement