Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // class 1
- package curso;
- import javax.swing.*;
- public class Chama {
- public static void main(String[] args){
- Calcula.valor1=8;
- Calcula.valor2=13;
- Calcula.Soma();
- JOptionPane.showMessageDialog(null, "a soma dos numeros: "+ Calcula.soma);
- }
- }
- // class 2
- package curso;
- public class Calcula {
- static double soma=0, valor1=0, valor2=0;
- public static void Soma(){
- soma = valor1+valor2;
- }
- }
- // maior e menor numero
- package curso;
- import javax.swing.*;
- public class Fibo {
- public static void main(String[] args){
- String vet =".";
- int s=0, v=0, t=0;
- s=0;
- v=1;
- for(int i=0; i<=10; i++){
- t=s;
- s = s + v;
- v = t;
- vet +=s;
- }
- JOptionPane.showMessageDialog(null, " valor " + vet);
- }
- }
- // ativi 2
- package curso;
- import javax.swing.*;
- public class Ati {
- static double[] vetor = new double[10];
- //static int i=0;
- public static void main(String[] args){
- for(int i=0; i<9; i++){
- vetor[i]=Double.parseDouble( JOptionPane.showInputDialog("DIga um valor") );
- }
- int j=0, n=0;
- double maior=0, menor=0, aux=0;
- // maior
- for(j=0; j<10; j++){
- for(n=j+1; n<10; n++){
- if(vetor[j] >= vetor[n]){
- aux = vetor[j];
- vetor[j] = vetor[n];
- vetor[n]=aux;
- }// if
- }//for2
- }//for
- JOptionPane.showMessageDialog(null, "maior "+ vetor[9]);
- JOptionPane.showMessageDialog(null, "menor "+ vetor[1]);
- }// main
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement