EDatos Tarea 1 - Cuarta Parte 0

Escrito por kaioken
viernes 17 de junio del 2005 @ 12:37 AM

4. Desarrolle los algoritmos correspondientes:
a) Multiplicación de los primeros 100 numeros primos.
La raiz cuadrada de un numero.
c) El mayor de tres numeros.
d) La calificacion de 5 estudiantes para 4 asignaturas de 3 puntuaciones

a)

Codigo:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php
public class Primos {

    public static 
void main(String[] args
    {
        
Primos $primo = new Primos();
        
int $resultado 1;
        
        for (
int i 1<= 100i++)
        {
            if(
$primo.setPrimos(i))
            {
                
$resultado i;
            }
        }
        
        
System.out.println($resultado);
    }
    
    public 
boolean setPrimos(int $number)
    {
        for(
int i 2<= $number 2i++) 
                {
                    if(
$number == 0
                    {
                       return 
false;
                     }
                }
                
                return 
true;
    }
}
?>




Codigo:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<?php
public class Raiz
{  
  public static 
void main(String[] args)
   {  
      
//numero a el que se le va a buscar la raiz cuadrada
      
double raiz 25;
      
      
double newraiz raiz 2;
      
double oldraiz;

      do
      {  
oldraiz newraiz;
         
newraiz = (oldraiz raiz oldraiz) / 2;
         
System.out.println(newraiz);
      }
      while (
Math.abs(newraiz oldraiz) > 1E-4);
   }
}
?>


c)

Codigo:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?php
public class Mayor {

    public static 
void main(String[] args
    {
        
int $a,$b,$c;
        
        
$a 1;
        
$b 7;
        
$c 5;
        
        
Mayor $big = new Mayor();
        
        
int $mayor1 $big.setMayor($a$b);
        
int $mayor2 $big.setMayor($mayor1$c);
        
        
System.out.println($mayor2);
        
    }
    
    public 
int setMayor(int $aint $b)
    {
        if (
$a $b)
        {
            
$b $a;
        }    
        return 
$b;
    }
}
?>


d)

Codigo:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<?php
public class Grade {

    public static 
void main(String[] args
    {
        
String[] $estudiantes = {"Max""Naruto""Sasuke""Rukawa""Sakuragi"};
        
String[] $materias = {"Prog Web""Deporte""Jutsu""Arte"};
        
String[] $notas = {"AAFF""FFAF""AAAA""AAAA""FAFF"};
        
        
System.out.println("(Asignaturas Del Semestre)");
        
        for(
int j 0$materias.lengthj++)
        {
            
System.out.print($materias[j] +" - ");
        }
        
        
System.out.println("\n");
        
        for (
int i 0$estudiantes.lengthi++)
        {
        
            
System.out.println(""+$estudiantes<i>+" - "+$notas<i>;
        }
    }
}
?>

Comentarios

Dejen sus comentarios MCUsers

  1. kaiokenjueves 19 de abril del 2007

  2. kaiokenjueves 19 de abril del 2007

    Codigo:

    1
    2
    3
    4
    5
    6
    <?php
    dfadf
    if()
    {
    }
    ?>

  3. kaiokenjueves 19 de abril del 2007

    nose
    d
    f
    df
    ad
    f
    nose coóodfodofo