The TRshady Forum became read-only in December 2014. The 10 year history will live on, in this archive.
Continue the discussion with the new home for the Eminem and Hip Hop discussion: HipHopShelter.com.

can someone help me to do this please? (java)

Talk and get help on Webmaster related topics such as programming, designing and advertising.
See WhoNeedsActions.com for Web Development Guides.

can someone help me to do this please? (java)

Postby 848lu » Nov 19th, '06, 12:16

hey can someone please help me to make sence of this code...please use comment above the code your explaining...thanks

import java.util.*;
import java.text.*;

public class MonthView {

/** List names of the month */
public final static String[] months = {
"January" , "February" , "March",
"April" , "May" , "June",
"July" , "August" , "September",
"October" , "November" , "December"
};
/** List the days in each month */
public final static int dom[] = {
31, 28, 31, /* jan, feb, mar */
30, 31, 30, /* apr, may, jun */
31, 31, 30, /* jul, aug, sep */
31, 30, 31 /* oct, nov, dec */
};

private void printMonth(int mm, int yy) {
// The number of days to leave blank at
// the start of this month.
int leadSpaces = 0;

System.out.println();
System.out.println(" " + months[mm] + " " + yy);

if (mm < 0 || mm > 11) {
throw new IllegalArgumentException(
"Month " + mm + " bad, must be 0-11");
}
GregorianCalendar cal = new GregorianCalendar(yy, mm, 1);
System.out.println("Su Mo Tu We Th Fr Sa");

// Compute how much to leave before before the first day of the month.
// getDay() returns 0 for Sunday.
leadSpaces = cal.get(Calendar.DAY_OF_WEEK)-1;

int daysInMonth = dom[mm];

if (cal.isLeapYear(cal.get(Calendar.YEAR)) && mm == 1) {
++daysInMonth;
}
// Blank out the labels before 1st day of the month
for (int i = 0; i < leadSpaces; i++) {
System.out.print(" ");
}
for (int i = 1; i <= daysInMonth; i++) {

// This "if" statement is simpler than messing with NumberFormat
if (i<=9) {
System.out.print(" ");
}
System.out.print(i);
if ((leadSpaces + i) % 7 == 0) { // Wrap if EOL
System.out.println();
} else {
System.out.print(" ");
}
}
System.out.println();
}
/**
* Sole entry point to the class and application.
* @param args Array of String arguments.
*/
public static void main(String[] args) {
int month, year;
MonthView mv = new MonthView();
if (args.length == 2) {
mv.printMonth(Integer.parseInt(args[0])-1, Integer.parseInt(args[1]));
} else {
Calendar today = Calendar.getInstance();
mv.printMonth(today.get(Calendar.MONTH), today.get(Calendar.YEAR));
}
}
}
User avatar
848lu
Renegade
Renegade
 
Posts: 2551
Joined: Jan 13th, '06, 17:43
Location: Your Girl-friends House

Postby 848lu » Nov 20th, '06, 15:00

any1 :flower:
The Game wrote:Your fanbase knew your gangsta is dying
So i won't stop till that wanksta retire
User avatar
848lu
Renegade
Renegade
 
Posts: 2551
Joined: Jan 13th, '06, 17:43
Location: Your Girl-friends House

Postby 848lu » Nov 21st, '06, 17:19

annnnyyyyy1 :'(
The Game wrote:Your fanbase knew your gangsta is dying
So i won't stop till that wanksta retire
User avatar
848lu
Renegade
Renegade
 
Posts: 2551
Joined: Jan 13th, '06, 17:43
Location: Your Girl-friends House

Postby °[~CHR!$~]° » Nov 21st, '06, 20:06

sry i would help but i know so much like you............nothin^^ :sweating:
User avatar
°[~CHR!$~]°
Addict
Addict
 
Posts: 11157
Joined: Nov 14th, '05, 17:11
Location: germany
Gender: Male

Postby 848lu » Nov 21st, '06, 20:27

em50inem wrote:sry i would help but i know so much like you............nothin^^ :sweating:


lol
The Game wrote:Your fanbase knew your gangsta is dying
So i won't stop till that wanksta retire
User avatar
848lu
Renegade
Renegade
 
Posts: 2551
Joined: Jan 13th, '06, 17:43
Location: Your Girl-friends House

Re: can someone help me to do this please? (java)

Postby C-Game » Jan 9th, '07, 12:31

848lu wrote:hey can someone please help me to make sence of this code...please use comment above the code your explaining...thanks

import java.util.*;
import java.text.*;

public class MonthView {
//This is assignin da months in string format to a string array named months
/** List names of the month */
public final static String[] months = {
"January" , "February" , "March",
"April" , "May" , "June",
"July" , "August" , "September",
"October" , "November" , "December"
};

//same assignin da days for each month

/** List the days in each month */
public final static int dom[] = {
31, 28, 31, /* jan, feb, mar */
30, 31, 30, /* apr, may, jun */
31, 31, 30, /* jul, aug, sep */
31, 30, 31 /* oct, nov, dec */
};

private void printMonth(int mm, int yy) {
// The number of days to leave blank at
// the start of this month.
int leadSpaces = 0;

//[b]prints a new line[/]b]
System.out.println();
System.out.println(" " + months[mm] + " " + yy);


//[b]checks if da month is within da array
//0 to 11 th elemant
//if it is true da IlligalArgumentException occurs


if (mm < 0 || mm > 11) {
throw new IllegalArgumentException(
"Month " + mm + " bad, must be 0-11");
}


//new object created
GregorianCalendar cal = new GregorianCalendar(yy, mm, 1);
System.out.println("Su Mo Tu We Th Fr Sa");

// Compute how much to leave before before the first day of the month.
// getDay() returns 0 for Sunday.
leadSpaces = cal.get(Calendar.DAY_OF_WEEK)-1;

int daysInMonth = dom[mm];

if (cal.isLeapYear(cal.get(Calendar.YEAR)) && mm == 1) {
++daysInMonth;
}
// Blank out the labels before 1st day of the month
for (int i = 0; i < leadSpaces; i++) {
System.out.print(" ");
}
for (int i = 1; i <= daysInMonth; i++) {

// This "if" statement is simpler than messing with NumberFormat
if (i<=9) {
System.out.print(" ");
}
System.out.print(i);
if ((leadSpaces + i) % 7 == 0) { // Wrap if EOL
System.out.println();
} else {
System.out.print(" ");
}
}
System.out.println();
}
/**
* Sole entry point to the class and application.
* @param args Array of String arguments.
*/
public static void main(String[] args) {
int month, year;
MonthView mv = new MonthView();
if (args.length == 2) {
mv.printMonth(Integer.parseInt(args[0])-1, Integer.parseInt(args[1]));
} else {
Calendar today = Calendar.getInstance();
mv.printMonth(today.get(Calendar.MONTH), today.get(Calendar.YEAR));
}
}
}


hope u got ur answer coz da rest of da codin is commmented
User avatar
C-Game
Band Leader
Band Leader
 
Posts: 7930
Joined: Jul 24th, '06, 19:02
Location: THRONE of the KING OF KINGS
Gender: Male

Postby 848lu » Jan 10th, '07, 20:01

damn....ur a gangsta ...thanks
The Game wrote:Your fanbase knew your gangsta is dying
So i won't stop till that wanksta retire
User avatar
848lu
Renegade
Renegade
 
Posts: 2551
Joined: Jan 13th, '06, 17:43
Location: Your Girl-friends House

Postby C-Game » Jan 10th, '07, 20:34

848lu wrote:damn....ur a gangsta ...thanks


np buddy
User avatar
C-Game
Band Leader
Band Leader
 
Posts: 7930
Joined: Jul 24th, '06, 19:02
Location: THRONE of the KING OF KINGS
Gender: Male


Return to Webmaster World



Who is online

Users browsing this forum: No registered users