Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


mangboi
do this for me plzz
1 Answer(s)      5 years and 11 months ago
Posted in : Java Interview Questions



Advertisement
View Answers

January 20, 2009 at 4:12 AM


Hi friend,

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

public class MonthView {

public final static String[] months = {
"January" , "February" , "March",
"April" , "May" , "June",
"July" , "August" , "September",
"October" , "November" , "December"
};

//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) {
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"); //can change to "M T W T F S S"
leadSpaces = cal.get(Calendar.DAY_OF_WEEK)-1; //adjust for "M T W T F S S" if desired
int daysInMonth = dom[mm];
if (cal.isLeapYear(cal.get(Calendar.YEAR)) && mm == 1) daysInMonth++;
for (int i = 0; i < leadSpaces; i++) {
System.out.print(" ");
}
for (int i = 1; i <= daysInMonth; i++) {
if (i<=9) System.out.print(" ");
System.out.print(i);
if ((leadSpaces + i) % 7 == 0) {
System.out.println();
}
else {
System.out.print(" ");
}
}
System.out.println();
}

public static void main(String[] args) {
int month, year;
MonthView mv = new MonthView();
Calendar today = Calendar.getInstance();
mv.printMonth(today.get(Calendar.MONTH), today.get(Calendar.YEAR));
}
}

-----------------------------------------

Visit for more informaton:

http://www.roseindia.net/java/

Thanks.

Amardeep


Related Tutorials/Questions & Answers:
do this for me plzz - Java Interview Questions
do this for me plzz  Given the no of days and start day of a month print the calender of that month . Startday will be given as integer... to print in the same line i.e., without printing a newline. 2)You do
Help me plzz
Help me plzz  Hello Roseindia.... I need ur help urgently... I am... project not web project so kindly provide me a help.... It will be good for me if u provide me all required files like; strtus.xml web.xml 2 Jsp pages thnx
Advertisements
plzz tell me java code for that diamond
plzz tell me java code for that diamond   1 131 13531 1357531 13531 131 1
help me to do it in jsp
help me to do it in jsp  if we click on a topic it should direct to another page in separate window i need to create a part of the web page which... to insert and update the topics via admin page. pls help me to do
helllppp plzz
helllppp plzz   Create a method sum of even to find the sum of Multiples of number 5 from 10 to 50, and use it in a program . it's a c# program plz i need the solution
need someone do it for me plz..people
need someone do it for me plz..people  write an application that displays a menue of three items in a restaurant as follows: 1.Cheeseburger 4.99... selection he or she has already made, ignore the selection-that is,do not add a second
hi plzz reply
hi plzz reply  in our program of Java where we r using the concept of abstraction Plz reply i m trying to learn java ...   means in language of coding we r not using abstraction this will be used only for making ideas
Why do the slashes change when the console gives me the error?
Why do the slashes change when the console gives me the error?   ..."; The console gives me back an error saying: java.io.FileNotFoundException: http...(Image.java:120) at java.lang.Thread.run(Thread.java:619) Why do the slashes change
i have a problem to do this question...pls help me..
i have a problem to do this question...pls help me..  Write a program that prompts the user to input an integer and the output the number with the digits reversed. For example if the input is 12345, the output should be 54321
inheritance....please help me friends...!!!... this is important project that i have to do it..
inheritance....please help me friends...!!!... this is important project that i have to do it..   Point ................. #x : int #y : int + Point() + Point(xCoordinate:int, YCoordinate:int) + getX() : int + getY() : int
do the combinations in java, pls help me its urhent - Development process
do the combinations in java, pls help me its urhent  import java.util.*; interface Expression { public void interpret(ArrayList exp); } class... one help me: action when condition1 and condition3 action when condition1
Run this code..plzz - Java Beginners
are defined in this example what you want to do please explain and send me full code
could you suggest me that in which area i have to do a project?i want a complete guidence to complete my project.
could you suggest me that in which area i have to do a project?i want a complete guidence to complete my project.  could you suggest me that in which area i have to do a project?i want a complete guidence to complete my project
cannot find symbol class array queue--plzz somebody help..
cannot find symbol class array queue--plzz somebody help..  import java.util.*; public class Test { public static void main(String[] args) { ArrayQueue<String> q = new ArrayQueue<String>(6); System.out.println
Reply me soon.........
Reply me soon.........  Any body plzz help.....how to get d checked details from previous page to current page and den insert into table
do the following
do the following  write a program to enter the string and do the following 1- count totle number of vowel 2- replace vowel 3- delete the charactor from given value 4- riverce the string 5- convert second word in upercase 6
The while and do
While and do-while      ... that the condition becomes false and the loop terminates. Have a look at do-while statement now. Here is the syntax: do { statement(s
how to do this?
how to do this?   Given any integer 2D array, design then implement a Java program that will add to each element in the array the corresponding column number and the corresponding row number. Then, it prints the array before
help me
help me  HI. Please help me for doing project. i want to send control from one jsp page to 2 jsp pages... is it possible? if possible how to do
php do while loop
php do while loop  Difference between do while loop and simple loop in PHP
php do while example
php do while example  Simple example of do while loop in PHP
php do while syntax
php do while syntax  How to create a do while loop in php. What is the syntax
help me
help me  i have done as u directed but nothing happens gud to me..... . i am using netbeans is that matter at all help me and take me out from trouble where to store jfree api to use it for j2ee based project
help me
help me  hi sir pls tell me how to use ajax form validatin from very simple way with two ot three text field pls help me use ajax in php my email id is:- rohit11tripathi@gmail.com pls sir give me some vasic information i know
help me
help me  please send me the java code to count the number of similar words in given string and replace that word with new one
sends me email
sends me email  How do I create a link that sends me email
php do while break
php do while break   receiving a Fatal saying cannot break/continue.. please suggest. Thank U
php do while false
php do while false   Is there any difference between FALSE and false
while and do while
while and do while  hello, What is the difference between a while statement and a do statement?   hello, A while statement checks at the beginning of a loop to see whether the next loop iteration should occur. A do
help me..
help me..   what are the component needed by grid computing, cloud computing and ubiquitous computing? discuss about the security of above computing. difference between that 3 computing
Help me
out from java output so how to do all dis
 

 

 

DMCA.com