+ 2
Give me a simple for loop code in creating November month calendar.
3 Answers
+ 5
here is your code:
public class Program
{
public static void main(String[] args){
String txt;
for (int i = 0;i <30;i++){
if ((i+1)%7 == 1){
txt = "Tue";
}
else if((i+1)%7 == 2){
txt = "Wed";
}
else if((i+1)%7 == 3 ){
txt = "Thu";
}
else if((i+1)%7 == 4){
txt = "Fri";
}
else if((i+1)%7 == 5){
txt = "Sat";
}
else if((i+1)%7 == 6){
txt = "Sun";
}
else{
txt = "Mon";
}
System.out.println((i+1) + " " + txt);
}
}
}
+ 2
Thanks
+ 2
Here it is...
public class Program
{
public static void main(String[] args){
String txt;
for (int i = 0;i <30;i++)
{
if ((i+1)%7 == 1)
{
txt = "Tue";
}
else if((i+1)%7 == 2)
{
txt = "Wed";
}
else if((i+1)%7 == 3 )
{
txt = "Thu";
}
else if((i+1)%7 == 4)
{
txt = "Fri";
}
else if((i+1)%7 == 5)
{
txt = "Sat";
}
else if((i+1)%7 == 6)
{
txt = "Sun";
}
else{
txt = "Mon";
}
System.out.println((i+1) + " " + txt);
}
}
}