Home Answers Viewqa Java-Beginners Output Previous or Next Day of the Month

 
 


Becky
Output Previous or Next Day of the Month
0 Answer(s)      a year and 3 months ago
Posted in : Java Beginners

Please Help! I need to create the following program:

Objective of this Program: (1) To learn about having programs decide what to do depending upon the data by using the if...then...else construct and (2) to start using some of the Java API's, by using the String class.

The program is to prompt the user (both computer science and drug dealers refer to their clients as "users") for the date of the month and whether they want the next day or the previous day. E.g., the user would see:

Enter todays date(1-30):

and after responding, the user would see:

Do you want the next or previous day:

The program should output the next day's or previous day's date: e.g, for the input of:

Enter todays date(1-30): 7

Do you want the next or previous day: next

Tomorrow is the 8th.

For the response of 'previous', one would see:

Yesterday was the 6th.

You should also check for erroneous input. Specifically, three possible bad inputs:

(1) the data is not between 1 and 30, inclusive

(2) one is asked the preceding date of the 1st

(3) one is asked the next day of the 30th

If bad input is given, then each of them should have an appropriate message telling of the bad input, e.g.,

Enter todays date(1-30): 36

gets the response:

Please enter a date between 1 and 30.

and the program would terminate. You terminate a program by the statement of System.exit(0);. It should be part of the 'then' clause statement. However, the following input sequence of:

Enter todays date(1-30): 30

Do you want the next or previous day: next

would generate:

There is no date after the 30th.

A simliar response is given for a response of "previous" when the current date is a 1. You do not have to verify whether one correctly types in 'next' or 'previous' correctly. I.e., if the user incorrectly types in the response, you are not responsible for what happens.

And then Extend the program to do the following:

Extend the output to handle the special cases which end in 1, 2, or 3. I.e., 1st, 2nd, 3rd, 21st, 22nd, 23rd. Remember that 11th, 12th, 13th are the correct output.

Verify that the input of 'next' and/or 'previous' is given correctly, and, if incorrect, print out an error statement and terminate the program. However, the response must be case insensitive. I.e., 'Next' or 'NEXT' are acceptable answers.

View Answers









Related Pages:
Output Previous or Next Day of the Month
Output Previous or Next Day of the Month   Please Help! I need... or previous day: The program should output the next day's or previous day's date... they want the next day or the previous day. E.g., the user would see: Enter todays
Getting Previous, Current and Next Day Date
Getting Previous, Current and Next Day Date   ... previous, current and next date in java. The java util package provides... the previous, current and next date to Date() constructor of java.util package
Mysql last day of month
Mysql last day of month       Mysql Last Day of Month is useful to provide you the last day... from Mysql Last Day of Month. To understand the example we use (Last Day (now
Mysql Date Previous Month
Mysql Date Previous Month       Mysql Date Previous Month is used to return the current and previous... that help you to describe Previous Month value. To understand this, we have
Mysql last day of month
Mysql last day of month     ... of Month'. To  understand and grasp the example we run LAST_DAY(now( )) that return the last day of the month. LAST_DAY(now( )) : The Query
Find Day of Month
Find Day of Month       This example explores how to find the day of a month and the day...; finds the day of a month and the day of a week by using get(field_name) method
Java get Next Day
Java get Next Day       In this section, you will study how to get the next day in java... day. cal.get(Calendar.DAY_OF_WEEK)+1- This will return the next day. Here
Get Last Day of The Month
Get Last Day of The Month     ... and a set of integer fields such as YEAR, MONTH, DAY, HOUR.. A Date object ... a code that helps you in getting the last day of the month. For this we have
Implementation of Day Class
the day. 3) Return the day. 4) Return the next day. 5) Return the previous day. 6...******* Set day: Sunday Next day: Monday Previous Day: Sunday... next; next = day + 1; return next; } public int previousDay
next and previous record in php
next and previous record in php  How to display next and previous records in PHP
to renew leave to next month
that leave in that particular month, it must be renewed to the next month so that he can apply leave for 2 days the next month...to renew leave to next month  i need to make a project where
NEXT and PREVIOUS Records - JSP-Servlet
NEXT and PREVIOUS Records  Dear Sir, In my Project i have next... requirement next,previous buttons should be placed at top of the page as well. For Example: Previous Next sid sname addr 1
PHP Previous Next Page - PHP
PHP Previous Next Page  PHP Previous Next PageIs it possible to create dynamic navigation using PHP and MYSQL? DO I need to create a class to create the next, previous buttons in PHP? I?m digging for a small as well as handy code
Java Find Next Date Example
have create a class where I have taken three integer fields for month, day... NextDateExample.java public class NextDateExample { int month, day, year; public NextDateExample() { month = 1; day = 1; year = 2000; } public NextDateExample
Date Next and Previous - Java Interview Questions
Date Next and Previous  In the example given here, DATE is displayed in DD/MM/YYYY format. Can anybody send me the code for getting DATE in MM/DD... StringToDate{ public static void main(String[] args){ try { String str_date 
Get first day of week
, it will display the actual day that displays like the following output... according to its field. It takes one field like: DAY_OF_WEEK, DAY_OF_MONTH etc... Get first day of week      
Find whether a date will be in the current quarter or the next quarter
box with values(1,2,3) , Day of the month in list box with values (Date as 1... quarter my month selected will correspond to september and my selected day of month... selected from the month list box (that is 1) will correspond to the next quarter 1st
Displaying checked checkbox in same page as well as print on another page ....also add next pages cheches checkbox into previous list
....also add next pages cheches checkbox into previous list  1..., it does not display previous page's selected checkboxes. So, i want such output, which can show previous pages selected checkbox as well as i aslo include next
how to find last day 0f any given month in mysql?
how to find last day 0f any given month in mysql?  how to find last day of any given month in mysql?   Hi Friend, Here is required code: DECLARE @dtDate DATETIME SET @dtDate = '8/18/2007' SELECT DATEADD(s,-1,DATEADD
PHP Date add 1 month
PHP Date add 1 month This example shows you how one month can be added... to add 1 month: <?php //PHP Example code to add one moth to a date...;.$todayDate."<br>"; //Add one day to today
Calendar Example
for performing action to display the next year, previous year, next month and previous month by calling SelectionAdapter class.  The gridLayout.numColumns...; In this section, you will study how the calendar shows the previous year
Disable next month at every first 3rd days Calendar.
Disable next month at every first 3rd days Calendar.  Hi all, may I know how to fix my calendar. I want it to disable next month at every first 3rd...) { alert('You can`t choose date every 3rd days at the next month
to display NEXT and previous option after 10 entries in java
to display NEXT and previous option after 10 entries in java  As after jsp code we refer to java for connectivity and i want that directly only 10 entries will be open and next there will be pages. so what would i do for coding
MySQL add month
DAY_HOUR YEAR_MONTH   Following...;2008-12-15', INTERVAL 1 MONTH) Output: 2009-01-15 Following example show how to add 2 months: SELECT DATE_ADD('2010-12-15', INTERVAL 2 MONTH) Output
Hi..How to Display Days by month - Java Beginners
Separate .Month by Month For Ex.. INPUT: ---------------- Year Month Day 2006 12 30 2008 12 12 --------------------- OUTPUT: 2007 Jan 31 Days 2007
Java Get Month
Java Get Month       In the previous Java examples, we have discussed about date functions... the current month of the existing year. This Java get month example is simply
Sql Date and Time Functions
;  The Tutorial illustrate a function to extract the day of week, name of month, name of day, day of year, number of week. Understand with Example...'. Query (DAYOFWEEK) :-Here is the query for extracting the day of week
Day for the given Date in Java
Day for the given Date in Java  How can i get the day for the user... month(1-12): "); int month=input.nextInt()-1; System.out.println...(year, month, dd)).getTime(); SimpleDateFormat f = new SimpleDateFormat("EEEE
Mysql Date Month
; Output:- +-------+ | Month | +-------+ | 12 | +-------+ 1... Mysql Date Month       Mysql Date Month is used to find out the value of current month. Understand
next button in servlet
next button in servlet  i want to add next,previous button to get next record in my servlet. can you explain the logic to do
How to compile & get output for JSP
How to compile & get output for JSP  HI My Roseindia friend has given... created a small jsp program in HTML and saved as Hello.jsp. And next i opened... and in the previous page i am getting Hello.jsp.txt and i am clicking on it.Then i am getting
How to use next and previous button(or href) for database table that is retrieved from MySQL DB.
How to use next and previous button(or href) for database table that is retrieved from MySQL DB.  Initially,display 7or10 records on a jsp pageand when click on the NEXT button(or href link) then display next 7 records
avaudioplayer next track
avaudioplayer next track  How to set next and previous track in AVAudioPlayer in iPhone?   soundIndex=4; data=[[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:[array objectAtIndex:soundIndex]] error
How to use next and previous button(or href) for database table that is retrieved from MySQL DB using jsp,jstl,javascript
How to use next and previous button(or href) for database table that is retrieved from MySQL DB using jsp,jstl,javascript  when click on the next button/link then it must display next 10 record from database and same for previous
Dialog and Console Input-Output
Prev: Dialog Box Output | Next: Example: Captitalize Java NotesDialog and Console Input-Output  This is similar to the previous program... output System.out.println("Take me to your leader, " + name
Mysql Date Get Month
for the month. Select Month(CURRENT_TIMESTAMP); Output... Mysql Date Get Month       The tutorial explains you the way to retrieve the current month. Understand
Java Next()
of next() method. Hence we get the following output. Here is the code of program... Java Next()       In this section, you will get the detailed explanation about the next() method
Same Day Agra Tour
Same Day Agra Tour We are offering Same Day Agra Tour that enables you to see the various tourists attractions in Agra in a single day. The Same Day Agra... of  previous stones, handicraft iand leather goods as souvenir. We offer
JDBC Next
JDBC Next       The Tutorial help in understanding JDBC Next. The program describe a code that gives you the number of rows in the table. The code include a class JDBC Next
DateFormatter in Flex4
DateFormatter in Flex4: The DateFormatter class formats a date in month, day...:DateFormatter id="dateFormatter" formatString="month: MM,  day: DD, year: YYYY"/> <mx:DateValidator id
JavaScript setUTCDate method
an integer value between 1 and 31 provided by the user that represents day of the date object's month. In this part of JavaScript method tutorial we... which setUTCDate() method will be called and it will set the date of month
Mysql date month name
Mysql date month name       The Tutorial elaborate an example from Date Month Name in Mysql. To get the current value for the month of the year ,we use the following Query:  
Day Format Example
Day Format Example       This example shows how to format day using Format class. In this program we use a pattern of special characters to day format. Description of the code
Java Previous Iterator
Java previous Iterator function is present in the listIterator Interface... direction. Java Previous Iterate Example import java.util.ArrayList; import java.util.ListIterator; public class previous { public static void
DateChooser in Flex4
. It has no Spark component. The DateChooser control contains the year, a month and a grid of the day of the month. It has columns labeled for the days... visible calendars. You can change a month by left or right arrow. Only single
JavaScript setDate method
object with an integer value between 1 and 31 that represents day of the current month. Syntax for using setDate() method is as follows : Syntax:  ... "dt". In the next line of code we have taken the date value inserted
Find the Day of the Week
Find the Day of the Week       This example finds the specified date of  an year and a day... time zone, locale and current time. The fields used:  DAY_OF_WEEK
Month Format Example
Month Format Example       This example shows how to format Month using Format class. In this program we use a pattern of special characters to Month format. Description
Java get number of Days in Month
Java get number of Days in Month   ... of days in the specified month. This example sets the year as 2008, month as Calendar.FEBRUARY and the date as 1 using the method calendar.set(year, month, date
Get Month Name Example
;" + month);   } } Output... Get Month Name Example     ... in understanding a how to get a 'Get Month Name Example'.For this we have a class

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.