Advertisement
emmit

FABIO

Aug 20th, 2014
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.58 KB | None | 0 0
  1. // class 1
  2.  
  3. package curso;
  4.  
  5. import javax.swing.*;
  6.  
  7. public class Chama {
  8.  
  9.     public static void main(String[] args){
  10.        
  11.        
  12.         Calcula.valor1=8;
  13.         Calcula.valor2=13;
  14.         Calcula.Soma();
  15.        
  16.         JOptionPane.showMessageDialog(null, "a soma dos numeros: "+ Calcula.soma);
  17.     }
  18.    
  19.    
  20.    
  21.    
  22. }
  23. // class 2
  24.  
  25. package curso;
  26.  
  27. public class Calcula {
  28.  
  29.     static double soma=0, valor1=0, valor2=0;
  30.    
  31.     public static void Soma(){
  32.        
  33.         soma = valor1+valor2;
  34.     }
  35.    
  36. }
  37. // maior e menor numero
  38.  
  39. package curso;
  40.  
  41. import javax.swing.*;
  42.  
  43. public class Fibo {
  44.    
  45.    
  46.     public static void main(String[] args){
  47.        
  48.          String vet =".";
  49.        
  50.         int s=0, v=0, t=0;
  51.        
  52.         s=0;
  53.         v=1;
  54.        
  55.         for(int i=0; i<=10; i++){
  56.            
  57.             t=s;
  58.             s = s + v;
  59.             v = t;
  60.             vet +=s;
  61.            
  62.            
  63.         }
  64.    
  65.         JOptionPane.showMessageDialog(null, " valor " + vet);
  66.        
  67.     }
  68. }
  69. // ativi 2
  70.  
  71. package curso;
  72.  
  73. import javax.swing.*;
  74.  
  75. public class Ati {
  76.    
  77.     static double[] vetor = new double[10];
  78.     //static int i=0;
  79.    
  80.     public static void main(String[] args){
  81.        
  82.         for(int i=0; i<9; i++){
  83.            
  84.             vetor[i]=Double.parseDouble( JOptionPane.showInputDialog("DIga um valor") );
  85.            
  86.         }
  87.        
  88.         int j=0, n=0;
  89.         double maior=0, menor=0, aux=0;
  90.        
  91.             // maior
  92.         for(j=0; j<10; j++){
  93.             for(n=j+1; n<10; n++){
  94.        
  95.                 if(vetor[j] >= vetor[n]){
  96.                     aux = vetor[j];
  97.                
  98.                     vetor[j] = vetor[n];
  99.                
  100.                     vetor[n]=aux;
  101.                
  102.                                
  103.                 }// if
  104.             }//for2
  105.         }//for
  106.        
  107.                    
  108.         JOptionPane.showMessageDialog(null, "maior "+ vetor[9]);
  109.        
  110.         JOptionPane.showMessageDialog(null, "menor "+ vetor[1]);
  111.        
  112.     }// main
  113.    
  114.    
  115.    
  116.    
  117.    
  118.  
  119. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement