More Eclipse Java coding... I was bored, okay?

Status
Not open for further replies.

Mesmerale

Banned
Messages
2,560
Role
  1. Diaper Lover
  2. Babyfur
  3. Sissy
So I'm in my Computer Science class, and everyone is correcting the tests we just took, and I've already finished...

Now we haven't had any coding projects in this class for awhile, and I really wanted to code something, so I went to the ACSL (American Computer Science League) website and looked at some past projects they had, and chose this one..

From 1996-1997, the Intermediate Division of Contest #1..

"The Biggest" ( If you can't see it, I dunno what to tell you. >.> )

So yeah, pretty awesome, as you can see. ^_^ And it was hard as hell to figure out how to code it, but after a few minutes, I figured something out.

I hope it's somewhat decent...
 

Mesmerale

Banned
Messages
2,560
Role
  1. Diaper Lover
  2. Babyfur
  3. Sissy
 
Last edited:

Mesmerale

Banned
Messages
2,560
Role
  1. Diaper Lover
  2. Babyfur
  3. Sissy
 
Last edited:

Mesmerale

Banned
Messages
2,560
Role
  1. Diaper Lover
  2. Babyfur
  3. Sissy
Whoot! Finally done editing all that stuff!

Apart from the quality of the code itself: How's it look? Are the forums "Indenting" functions being used to their fullest, d'ya think?

I think it looks nice. ^_^
 

mizzycub

Est. Contributor
Messages
1,615
Role
  1. Adult Baby
  2. Diaper Lover
  3. Babyfur
Ooh, cool. I shall try to come up with a python program to solve it.
 

Mesmerale

Banned
Messages
2,560
Role
  1. Diaper Lover
  2. Babyfur
  3. Sissy
Ooh, cool. I shall try to come up with a python program to solve it.

Whoot! :D

I'm gonna do the senior division now, and then maybe the junior 'cause I love doing everything completely. (Depending on what it is. ^_^)
 

PupKommodore

Est. Contributor
Messages
377
Role
  1. Diaper Lover
  2. Diaperfur
  3. Little
  4. Other
Haha, I'm in an intro to programming class where the main language we use is Java. The only programs we've made so far are short, small programs that check to see if a number is either prime or composite :D Most of what you have there is still foreign to me.
 

Mesmerale

Banned
Messages
2,560
Role
  1. Diaper Lover
  2. Babyfur
  3. Sissy
Haha, I'm in an intro to programming class where the main language we use is Java. The only programs we've made so far are short, small programs that check to see if a number is either prime or composite :D Most of what you have there is still foreign to me.

I am going to give you the most important and helpful advice that you'll ever hear...

Read whatever textbook you are given! Cover to cover!

You will learn so much before it's taught to you, and you'll probably understand how to use it.

There will be example programs that will show you how something works, and how to use it.

You will be able to use methods that the people around you haven't even heard of yet, and it will help you a lot.

Read. That. Book.

And one more thing. For the love of god, remember the semicolon. :)
 

PupKommodore

Est. Contributor
Messages
377
Role
  1. Diaper Lover
  2. Diaperfur
  3. Little
  4. Other
Oh yeah, I've been able to get ahead a of the class a little quicker because I read the text book in advance. Here's a little program I made that'll determine the day of the week for any date in the 20th century.

Code:
public class TrivialApplication 
{

	public static void main(String args[]) 
	{	
		
		EasyReader console = new EasyReader();
		
		// Do-loop loops the program
		int answer=1;	
		do	
		{
			// Program allows the user to enter a date
			System.out.print("\nMonth=		");
			int month=console.readInt();
			System.out.print("\nDay=		");
			int day=console.readInt();
			System.out.print("\nYear=		");
			int year=console.readInt();
			
			// Variables that affect 'total'
			int yeartrunc=year-1900;
			int truncdiv=yeartrunc/4;
			int total=yeartrunc+day+truncdiv;
		
			// If-statements add to 'total' depending on the month entered
			if (month==1)
				total=total+1;
			else if (month==2)
				total=total+4;	
			else if (month==3)
				total=total+4;
			else if (month==4)
				total=total+0;
			else if (month==5)
				total=total+2;
			else if (month==6)
				total=total+5;
			else if (month==7)
				total=total+0;
			else if (month==8)
				total=total+3;
			else if (month==9)
				total=total+6;
			else if (month==10)
				total=total+1;
			else if (month==11)
				total=total+4;
			else if (month==12)
				total=total+6;
			
			if (year%4==0&&(month==1||month==2))
				total=total-1;
			
			// Program outputs the day on which the date entered falls on
			if (total%7==1)
				System.out.println("\nThis date falls on a Sunday");
			else if (total%7==2)
				System.out.println("\nThis date falls on a Monday");
			else if (total%7==3)
				System.out.println("\nThis date falls on a Tuesday");
			else if (total%7==4)
				System.out.println("\nThis date falls on a Wednesday");
			else if (total%7==5)
				System.out.println("\nThis date falls on a Thursday");
			else if (total%7==6)
				System.out.println("\nThis date falls on a Friday");
			else if (total%7==0)
				System.out.println("\nThis date falls on a Saturday");
			
			// Program asks the user whether or not they would like to enter another date
			System.out.print("\nWould you like to enter another date? (Yes-1 No-2): ");
				answer=console.readInt();
		
		}while (answer==1);
	}
}
 
Status
Not open for further replies.
Top