Está en la página 1de 2

//Wyvern package menu_4_opciones; import java.util.

Scanner; public class Menu_4_opciones { public static void main(String[] args) { byte a,b,c,d,e,f,x,suma; float g,h; Scanner w=new Scanner(System.in); System.out.println("Selecciona alguna opcion para 2 valores"); System.out.println("1=Sumar"); System.out.println("2=Restar"); System.out.println("3=multiplicar"); System.out.println("4=Dividir"); x=w.nextByte(); if(x==1){ System.out.println("Escribe el primer sumando"); a=w.nextByte(); System.out.println("Escribe el segundo sumando"); b=w.nextByte(); suma=oper_suma(a,b); System.out.println("El resultado de la suma es"+"="+suma); } else if (x==2){ System.out.println("Escribe el valor del minuendo"); c=w.nextByte(); System.out.println("Escribe el valor del sustraendo"); d=w.nextByte(); System.out.println("La difererncia es"+"="+oper_resta(c,d)); } else if(x==3){ System.out.println("Escribe el valor del multiplicando"); e=w.nextByte(); System.out.println("Escribe el valor del multiplicador"); f=w.nextByte(); System.out.println("El producto es"+"="+oper_mult(e,f));

} else { System.out.println("Escribe el valor del dividendo"); g=w.nextFloat(); System.out.println("Escribe el valor del divisor"); h=w.nextFloat(); System.out.println("El cociente es "+"="+ oper_div(g,h)); } }

public static byte oper_suma(byte a, byte b){ return(byte)(a+b); } public static byte oper_resta(byte c, byte d){ return (byte)(c-d); } public static byte oper_mult(byte e, byte f){ return (byte)(e*f); } public static float oper_div(float g, float h){ return (float)(g/h); }
}

Gerardo Vital Hernndez

También podría gustarte