Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
- */
- package com.mycompany.problema_7;
- /**
- *
- * @author ianto
- */
- import java.util.*;
- public class Problema_7 {
- public static void main(String[] args) {
- int opcion = 0;
- Scanner entrada = new Scanner(System.in);
- boolean salir = false;
- while(!salir) {
- System.out.println("1. Multiplicación");
- System.out.println("2. División");
- System.out.println("3. Salir");
- System.out.println("Ingrese una opcion");
- opcion = entrada.nextInt();
- switch(opcion){
- case 1:
- int numero1, numero2;
- int res_multi = 0;
- int contador = 0;
- System.out.println("\nMULTIPLICACION\n");
- System.out.println("Ingrese Un Numero");
- numero1 = entrada.nextInt();
- System.out.println("Ingrese El Numero Para Multiplicar");
- numero2 = entrada.nextInt();
- for(int i = 1; i <= numero2; i++) {
- res_multi += numero1;
- }
- System.out.println("\nResultado: " + res_multi);
- presioneEnter();
- break;
- case 2:
- int dividendo;
- int divisor;
- int cociente = 0;
- System.out.println("\nDIVISION\n");
- System.out.println("Ingrese El Dividendo");
- dividendo = entrada.nextInt();
- System.out.println("Ingrese El Divisor");
- divisor = entrada.nextInt();
- if(divisor == 0){
- System.out.println("No Se Puede Dividir Entre 0");
- presioneEnter();
- }else{
- while(dividendo >= divisor) {
- cociente ++;
- dividendo = dividendo - divisor;
- }
- System.out.println("Cociente: " + cociente);
- System.out.println("Residuo: " + dividendo);
- presioneEnter();
- }
- break;
- case 3:
- salir = true;
- break;
- default:
- System.out.println("Opcion No Valida");
- }
- }
- }
- public static void presioneEnter() {
- System.out.println("\nPresione Enter Para Mostrar El Menu Nuevamente");
- Scanner entrada = new Scanner(System.in);
- entrada.nextLine();
- }
- }
Add Comment
Please, Sign In to add comment