Results 1 to 3 of 3

Thread: Help with this...

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2008
    Posts
    9

    Help with this...

    I want to do this...

    Enter the day of birth: 10
    Enter the month of birth: 2
    Enter the year of birth: 1986

    You were born in: February

    I only now how to do this in vb, this is the code that i used...

    Code:
    '// Declaração de Variáveis
        Dim dia, ano, i As Integer
        Dim meses(12), resposta As String
    
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            '// Inicialização de Variáveis
            meses(1) = "Janeiro"
            meses(2) = "Fevereiro"
            meses(3) = "Março"
            meses(4) = "Abril"
            meses(5) = "Maio"
            meses(6) = "Junho"
            meses(7) = "Julho"
            meses(8) = "Agosto"
            meses(9) = "Setembro"
            meses(10) = "Outubro"
            meses(11) = "Novembro"
            meses(12) = "Dezembro"
    
            Do
                '// Entrada de Dados
                dia = InputBox("Entre com o dia do nascimento do aluno:")
                meses(i) = InputBox("Entre com o mês do nascimento do aluno:")
                ano = InputBox("Entre com o ano do nascimento do aluno:")
    
                '// Processamento de Dados
                For i = meses(i) To meses(i)
    
                    '// Saida de Dados
                    MsgBox("O estudante nasceu em " & dia & " de " & meses(i) & " de " & ano)
                Next
    
                '// Perguntar se Quer Continuar
                resposta = InputBox("Deseja Continuar S/N?:")
                resposta = resposta.ToUpper
            Loop Until (resposta.Equals("N"))
            Close()
        End Sub
    End Class

  2. #2
    PowerPoster eranga262154's Avatar
    Join Date
    Jun 2006
    Posts
    2,201

    Re: Help with this...

    Are you want to do it in Java? If not this question is not related to Java, and moderators should move this to the proper sub-forum.
    “victory breeds hatred, the defeated live in pain; happily the peaceful live giving up victory and defeat” - Gautama Buddha

  3. #3
    Arabic Poster ComputerJy's Avatar
    Join Date
    Nov 2005
    Location
    Happily misplaced
    Posts
    2,513

    Re: Help with this...

    This is how you can do it
    Code:
    import java.util.Scanner;
    
    public class Main
    {
    	public static void main(String[] args) throws Exception
    	{
    		String[] months =
    		{
    			"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"
    		};
    		Scanner s = new Scanner(System.in);
    		do
    		{
    			System.out.println("Enter the month of birth: ");
    			int month = s.nextInt();
    			if (month <= 12 && month > 0)
    				System.out.println("You were born in: " + months[month - 1]);
    			System.out.println("Do you want to continue? (Y/N)");
    		} while (((char) System.in.read()) == 'Y');
    	}
    
    	private Main()
    	{
    	}
    }
    "I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
    My Blog

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width