Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Aluno : Alan Cesar
- //Projeto: Unicarioca
- //Data : 22/03/2017
- import javax.swing.JOptionPane;
- public class Vetor {
- private int vet[];
- public Vetor(int _n){
- this.vet=new int[_n];
- }
- public void setVet(){
- try{
- int n=this.vet.length;
- for(int c=0;c<n;c++){
- String aS=JOptionPane.showInputDialog("Digite o Array : "+c);
- int a=Integer.parseInt(aS);
- this.vet[c]=a;
- }
- for(int c=0;c<n;c++){
- String sX="Vetor : "+this.vet[c];
- JOptionPane.showMessageDialog(null,sX);
- } }catch(Exception e){
- System.out.println("Erro : "+e.getMessage());
- }
- }
- public void maiorVet(){
- int n=this.vet.length;
- int maior=0;
- int c;
- for(c=0;c<n;c++){
- if(this.vet[c]>maior){
- maior=this.vet[c];
- }
- }
- String vM="Maior vetor : "+maior;
- JOptionPane.showMessageDialog(null,vM);
- }
- public static void main(String[] args) {
- Vetor obj=new Vetor(3);
- obj.setVet();
- obj.maiorVet();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement