Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Program Description: The program prompts for today\'s date and the user\'s birth

ID: 3625893 • Letter: P

Question

Program Description:
The program prompts for today's date and the user's birthday. Each
prompt lists the range of values from which to choose. Notice that
the range of days printed is based upon the number of days in the
month the user typed.
The program prints the "absolute day of the year" for today and the
birthday. This is a date's place within the year from 1 to 365.
January 1st is absolute day #1 and December 31st is #365. Lastly
the program prints the number of days until the user's next
birthday. Different messages appear if the birthday is today or
tomorrow.
The following are four runs of your program and their expected output (user
input is bold and underlined):
This program tells you how many days it will be until your next birthday.
Please enter today's date:
What is the month (1-12)? 7
What is the day (1-31)? 24
7/24 is day #205 of 365.
Please enter your birthday:
What is the month (1-12)? 11
What is the day (1-30)? 6
11/6 is day #310 of 365.
Your next birthday is in 105 days.
-------
This program tells you how many days it will be until your next birthday.
Please enter today's date:
What is the month (1-12)? 9
What is the day (1-30)? 22
9/22 is day #265 of 365.
Please enter your birthday:
What is the month (1-12)? 3
What is the day (1-31)? 17
3/17 is day #76 of 365.
Your next birthday is in 176 days.
--------
This program tells you how many days it will be until your next birthday.
Please enter today's date:
What is the month (1-12)? 2
What is the day (1-28)? 14
2/14 is day #45 of 365.
Please enter your birthday:
What is the month (1-12)? 2
What is the day (1-28)? 15
2/15 is day #46 of 365.
Wow, your birthday is tomorrow!
------
This program tells you how many days it will be until your next birthday.
Please enter today's date:
What is the month (1-12)? 12
What is the day (1-31)? 25
12/25 is day #359 of 365.
Please enter your birthday:
What is the month (1-12)? 12
What is the day (1-31)? 25
12/25 is day #359 of 365.
Happy birthday!
---------
Since this is an interactive program, it behaves differently when given different input.
The examples above do not show all possible cases.
You may assume that all user input is valid; that when prompted for a date, the user will
enter an integer in a valid range. You may also assume that your program is not run in a
leap year, so February always has 28 days.
Style Guidelines:
To receive full credit, you must have at least 4 non-trivial methods in your
program besides main. Use methods for structure and to reduce redundancy.
You should also utilize parameters and return values appropriately to pass
information throughout your code.
See the textbook (pgs. 283 – 288) for information about "procedural design
heuristics" to help understand what constitutes a good method. Each method
should perform a single clear and coherent task. No one method should do too
large a share of the overall work. As a very rough estimate, a method whose
body (excluding the header and closing brace) has more than 15-20 lines is
likely too large and may lose points.
For this assignment you are limited to language features in Chapters 1 through
4, in addition to logical operators such as && and || described in book section
5.3. You are especially forbidden from using Java's built-in date libraries such
as Date or GregorianCalendar.

Explanation / Answer

please rate - thanks

import java.util.*;
public class daysbetweendates
{public static void main(String [] args)
{int month, day,doy,bmonth,bday,bDOY,d,diff;
Scanner in=new Scanner(System.in);
System.out.println("This program tells you how many days it will be until your next birthday.");
System.out.println("Please enter today's date:9");
month=getdata("What is the month",12,in);
d=getdays(month);
day=getdata("What is the day",d,in);
doy=getDOY(month,day);
System.out.println("Please enter your birthday: ");
bmonth=getdata("What is the month",12,in);
d=getdays(bmonth);
bday=getdata("What is the day",d,in);
bDOY=getDOY(bmonth,bday);
printmessage(getDiff(doy,bDOY));




}
public static void printmessage(int d)
{if(d==0)
   System.out.println("Happy Birthday");
else if (d==1)
   System.out.println("Wow, your birthday is tomorrow");
else
   System.out.println("Your next birthday is in "+d+" days: ");
}
public static int getDiff(int d1,int d2)
{if(d1>d2)
    return d2+(365-d1);

else
    return d2-d1;
}
public static int getDOY(int month, int day)
{int daysinmonth;
int days=0,i;
             
for (i=1;i<month;i++)       //go up to that month add how many days in the month
    { days+=getdays(i);              
     }
days+=day;
System.out.println(month+"/"+day+" is day #"+days+" of 365");                        
return days;   
}
public static int getdata(String mess, int max,Scanner in)
{System.out.print(mess+"(1-"+max+")? ");
return in.nextInt();
}

public static int getdays(int month)
{int days;
switch(month)
    {case 9:
    case 4:
    case 6:
    case 11: days=30;
                 break;
    case 2:   days=28;
              break;
    default: days=31;
    }
return days;
}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote