




























































































Estude fácil! Tem muito documento disponível na Docsity
Ganhe pontos ajudando outros esrudantes ou compre um plano Premium
Esta página não é visível na pré-visualização
Não perca as partes importantes!





























































































int n, first = 0 , second = 1 , next, c; printf("Enter the number of terms \n "); scanf("%d",&n); printf("First %d terms of Fibonacci series are :- \n ",n); for ( c = 0 ; c < n ; c++ ) { if ( c <= 1 ) next = c; else { next = first + second; first = second; second = next; } printf("%d \n ",next); }
Exemplo de Programação Orientada a Objetos import javax.swing.JOptionPane; public class OddEven { private int input; public OddEven() { } public static void main( final String[] args) { OddEven number = new OddEven(); number.showDialog(); } public void showDialog() { try { this .input = Integer.parseInt(JOptionPane.showInputDialog("Please enter a number.")); this .calculate(); } catch ( final NumberFormatException e) { System.err.println("ERROR: Invalid input. Please type in a numerical value."); } } private void calculate() { if (( this .input % 2 ) == 0 ) { JOptionPane.showMessageDialog( null , "Even"); } else { JOptionPane.showMessageDialog( null , "Odd"); } } }
Conceitos de Orientação a Objetos
Conceitos de Orientação a Objetos
Conceitos de Orientação a Objetos
Conceitos de Orientação a Objetos