Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > General Coding
You last visited: Today at 03:48

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



Java Programming Help Again please :'(

Discussion on Java Programming Help Again please :'( within the General Coding forum part of the Coders Den category.

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Dec 2009
Posts: 12
Received Thanks: 0
Java Programming Help Again please :'(

How do i do this program???

Create an array that will Input a year (valid years are starting from 1900 onwards) then output the index number and the animal sign of the entered year. These are the sequence of the animal signs: RAT, OX, TIGER, RABBIT, DRAGON, SNAKE, HORSE, SHEEP, MONKEY, ROOSTER, DOG, PIG.

Sample output:

Enter a year: 1200
<<VALID INPUT STARTS AT 1900>>
Enter a year: 1984

The index number is 0
The animal sign of a person born in the year 1984 is "RAT"

process completed.

how do i do this? so confusing ..this is an activity in my school. Hope you can help me thanks !
zepolzirk is offline  
Old 10/06/2011, 09:48   #2

 
Obilee's Avatar
 
elite*gold: 144
Join Date: May 2007
Posts: 62,459
Received Thanks: 29,541
Code:
import java.io.IOException;
import java.util.Scanner;




public class TestMain {
  public static void main(String args[]) throws IOException {
	 
	  boolean legit = false;
	  Scanner s = new Scanner(System.in);	    
	  String[] animals = {"RAT", "OX", "TIGER", "RABBIT", "DRAGON", "SNAKE", "HORSE", "SHEEP", "MONKEY", "ROOSTER", "DOG", "PIG"};
	  
	  
	  while(!legit){
		  System.out.print("Enter a year: ");
		  int year = s.nextInt();
		  
		  if(year < 1900)
			  System.out.println("<<VALID INPUT STARTS AT 1900>>");
		  else{
			legit = true;
			
			 /**  OUTPUT WITH THE YEAR*/
		  }		  
	  }
  }
}
how to get the right animal is the task for you, i wont do all the stuff for you :P
Obilee is offline  
Reply


Similar Threads Similar Threads
Java Programming
10/11/2008 - CO2 Programming - 10 Replies
Hi guys, i am an experienced 2 year computer science HL java programmer :P just wondering where to start off to making programs for co? i wana make a new auto-clicker with timed clicks for intensify and a guard leveler :P



All times are GMT +1. The time now is 03:49.


Powered by vBulletin®
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2025 elitepvpers All Rights Reserved.