Need comments added please.
public class TenDate
{
private int NMnth;
private int NDy;
private int NYr;
private String [] MnthNm =
{"", "January", "February",
"March", "April", "May", "June", "July",
"August",
"September", "October", "November", "December"};
private int [] MnthD =
{0, 31, 28, 31, 30, 31, 30, 31, 31,
30, 31, 30, 31};
public TenDate()
{
NMnth = 1;
NDy = 1;
NYr = 1900;
}
public TenDate(int Mnth, int Dy, int Yr)
{
NMnth = Mnth;
NDy = Dy;
NYr = Yr;
}
public void SetDate(int Mnth, int Dy, int Yr)
{
NMnth = Mnth;
NDy = Dy;
NYr = Yr;
}
public int GetMonth()
{
return NMnth;
}
public void SetMonth(int IMnth)
{
if(IMnth > 0 && IMnth
< 13)
NMnth =
IMnth;
else
NMnth= 1;
}
public int GetDay()
{
return NDy;
}
public int GetYear()
{
return NYr;
}
public void SetDay(int IDy)
{
if(IDy > 0 && IDy <=
MnthD[NMnth])
NDy= IDy;
if(NMnth == 2 && IDy == 29
&& LeapYr())
NDy= IDy;
else
NDy = 1;
}
public void SetYear(int IYr)
{
NYr = IYr;
}
public boolean LeapYr()
{
if((NYr % 400 == 0) || (NYr % 4 ==
0 && NYr % 100 != 0))
return
true;
else
return
false;
}
public String DateString()
{
return(NMnth + "-" + NDy + "-" +
NYr);
}
public int DyInMnth()
{
if(LeapYr() && NMnth ==
2)
return
MnthD[NMnth] + 1;
else
return
MnthD[NMnth];
}
public int ConvDOY()
{
int DOY = 0;
for(int i = 1; i < NMnth;
i++)
{
if(LeapYr()
&& i == 2)
DOY += 29;
else
DOY += MnthD[i];
}
DOY += NDy;
return DOY;
}
public int DyLft()
{
return 365 - ConvDOY();
}
public void NewDy(int Days)
{
int DLoop = Days / 30 + 3;
int j, DoneDy = 0, DyInMnth,
MinusDy;
for(j = 1; j <= DLoop;
j++)
{
if(DoneDy ==
1)
return;
switch(NMnth)
{
case 9:
case 4:
case 6:
case 11:
DyInMnth = 30;
break;
case 2: DyInMnth
= 28;
if(NYr % 4 ==
0)
{
if(NYr % 100 != 0)
DyInMnth = 29;
else
if(NYr % 400 == 0)
DyInMnth =
29;
}
break;
default:
DyInMnth = 31;
}
MinusDy =
DyInMnth - NDy;
if(Days >
MinusDy)
{
NMnth =++ NMnth % 13;
if(NMnth == 0)
{
NYr++;
NMnth++;
}
Days -= MinusDy;
NDy = 0;
}
else
{
NDy += Days;
DoneDy = 1;
}
}
}
}
We need at least 10 more requests to produce the answer.
0 / 10 have requested this problem solution
The more requests, the faster the answer.
Need comments added please. public class TenDate { private int NMnth; private int NDy;...
public class Date { private int month; private int day; private int year; /** default constructor * sets month to 1, day to 1 and year to 2000 */ public Date( ) { setDate( 1, 1, 2000 ); } /** overloaded constructor * @param mm initial value for month * @param dd initial value for day * @param yyyy initial value for year * * passes parameters to setDate method */ public Date( int mm, int dd, int yyyy )...
Need help figuring out what would be the all 12 days output public class Date { private int day; private int month; private int year; private static int tracker; public Date() { this(1, 1, 2000); System.out.println("4"); } public Date(int year) { this(1, 1, year); System.out.println("3"); } public Date(int month, int year) { this(1, month,...
Programming Exercise 11-8 PROBLEM:The class dateType defined in Programming Exercise 6 prints the date in numerical form. Some applications might require the date to be printed in another form, such as March 24, 2019. Derive the class extDateType so that the date can be printed in either form. Add a member variable to the class extDateType so that the month can also be stored in string form. Add a member function to output the month in the string format, followed...
I'm having trouble with the daysSince() Method in bold at the end of the program public class Date { static final int [] daysInMonth = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; private int day, month, year; public Date() { day = 1; month = 1; year = 2000; } public Date(int d, int m, int y) { day = d; month = m; year = y; } public Date (String s) { setDate(s);...
#include "stdafx.h" #include <iostream> using namespace std; class dateType { private: int dmonth; int dday; int dyear; public: void setdate (int month, int day, int year); int getday()const; int getmonth()const; int getyear()const; int printdate()const; bool isleapyear(int year); dateType (int month=0, int day=0, int year=0); }; void dateType::setdate(int month, int day, int year) { int numofdays; if (year<=2008) { dyear=year;...
Hello, I have a bug in my code, and when I run it should ask the user to enter the month and then the year and then print out the calendar for the chosen month and year. My problem with my code is that when I run it and I enter the month, it doesn't ask me for the year and it prints all the years of the month I chose. Please help! Code: #include "calendarType.h" #include <iostream> using namespace...
(IN JAVA ) Given the class Date that can prints the date in numerical form. Some applications might require the date to be printed in another form, such as March 24, 2005. Please do the following: Derive the class ExtDate so that the date can be printed either form. Add a data member to the class ExtDate so that the month can also be stored in string form. Add a method to output the month in the string format followed...
I need to create a Java class file and a client file that does the following: Ask user to enter Today’s date in the form (month day year): 2 28 2018 Ask user to enter Birthday in the form (month day year): 11 30 1990 Output the following: The date they were born in the form (year/month/day). The day of the week they were born (Sunday – Saturday). The number of days between their birthday and today’s...
C++ problem 11-6 In Programming Exercise 2, the class dateType was designed and implemented to keep track of a date, but it has very limited operations. Redefine the class dateType so that it can perform the following operations on a date, in addition to the operations already defined: Set the month. Set the day. Set the year. Return the month. Return the day. Return the year. Test whether the year is a leap year. Return the number of days in...
Write Junit Test for the following class below: public class Turn { private int turnScore; private Dice dice; private boolean isSkunk; private boolean isDoubleSkunk; public Turn() { dice = new Dice(); } public Turn(Dice dice) { this.dice = dice; } public void turnRoll() { dice.roll(); if (dice.getDie1Value() == 1 || dice.getDie2Value() == 1 && dice.getLastRoll() != 2) { turnScore = 0; isSkunk = true; } else if (dice.getLastRoll() == 2) { turnScore = 0; isDoubleSkunk = true; } else { ...