Rosetta Code:Add a Task: Difference between revisions

m
Reverted edits by Venkat1003 (talk) to last revision by Mwn3d
(→‎Create the page: It will provide any day like Monday, Tuesday, Wednesday, Thursday, Friday , Saturday and Sunday on every month for specific year and also range.)
m (Reverted edits by Venkat1003 (talk) to last revision by Mwn3d)
Line 10:
===Create the page===
Come up with a title for your task (look at [[:Category:Programming Tasks|the current tasks]] to see what kind of name you should choose), type it in the search bar, and click "Go". There will be a "Create page" link on the resulting page somewhere. Click that, and you can begin editing.
 
It will provide any day like Monday, Tuesday, Wednesday, Thursday, Friday , Saturday and Sunday on every month for specific year and also range.
 
===Draft vs non-draft===
Not all tasks are immediately ready to be thrown at the casual Rosetta Code participant. Some need a review or draft phase before they're in good shape.
Line 53 ⟶ 50:
Where relevant, '''sample input''' should be included; it gives task solvers something to work with.
 
===Example code===
package com.deere.core.dates;
It is usually a good idea to '''have at least one example implementation completed, tested, and working''' ''before'' you start writing the description of the task, as well as '''a sample of correct output.''' It is usually a good idea if this first example shows its output; even if it isn't strictly necessary for the completion of the task, it helps other implementers understand the task and what they need to do.
 
import java.text.DateFormatSymbols;
import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.Locale;
import java.util.Scanner;
 
public class LastSunday {
 
/**
* Venkata Janga
* @param args
*/
public static void main(String[] args) {
System.out.println("Please enter year to want to see........");
Scanner scanner = new Scanner(System.in);
int year = scanner.nextInt();
System.out.println("Please enter how many years you want to see the dates");
Scanner yearEnd = new Scanner(System.in);
int endYear = yearEnd.nextInt();
for(int year1=year;year1<=endYear;year1++){
GregorianCalendar calander = new GregorianCalendar(year, 0, 1);
System.out.println("===================================================Begin");
for (String mon : new DateFormatSymbols(Locale.US).getShortMonths()) {
if (!mon.isEmpty()) {
int totalDaysOfMonth = calander.getActualMaximum(Calendar.DAY_OF_MONTH);
calander.set(Calendar.DAY_OF_MONTH, totalDaysOfMonth);
/**
* 1--> FRIDAY
* 2--> THURSDAY
* 3--> WEDNES DAY
* 4--> TUESDAY
* 5--> MONAY
* 6--> SUNDAY
* 7--> SATURADAY
* */
int daysToRollBack = (calander.get(Calendar.DAY_OF_WEEK) + 6) % 7;
int day = totalDaysOfMonth - daysToRollBack;
calander.set(Calendar.DAY_OF_MONTH, day);
System.out.printf("%d %s %d\n", year1, mon, day);
calander.set(year,calander.get(Calendar.MONTH) + 1, 1);
}
}
System.out.println("===================================================End");
}
}
 
In short, solve your own task. Show us how it's done.
}
 
==Additional information==