Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Practico0;
- import java.util.Scanner;
- import Practico0.Helper;
- public class Ejercicio4 {
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- hacer();
- }
- public static void hacer(){
- Scanner sn = new Scanner(System.in);
- String opcion;
- do {
- int numero = ingresarValor();
- esCompuesto(numero);
- System.out.println("Desea ingresar otro valor(s/n)");
- opcion = sn.next();
- }while(!opcion.equals("n"));
- System.out.println("Gracais :D");
- }
- static void esCompuesto(int numero){
- int contador = 0;
- for(int I = 1; I <= numero; I++){
- if((numero % I) == 0){
- contador++;
- }
- }
- if(contador <= 2){
- System.out.println(numero + " Es un numero primo");
- }else{
- System.out.println(numero + " Es un numero compuesto");
- }
- }
- public static Integer ingresarValor() {
- Helper help = new Helper();
- @SuppressWarnings("static-access")
- Integer num = help.getInteger("Ingrese un numero positivo ");
- return num;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment