Total members 11895 |It is currently Sun Dec 22, 2024 5:09 am Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





Programming Calendar in java:
My program is supposed to take a date as in input and return the next day as an output. The input format is MM/DD/YY , and the output should be Month DD, YYYY, i.e. September 09, 2009. I was provided Date and Calendar classes, but there are missing parts specified with TODO comments within the code. Unfortunately, Im having a hard time finishing the missing parts and Im wondering if anyone can help. I attached my java code with this. If it would be easier to post my code too instead of just attaching it, just let me know.
Code:

package cs2000
.Lab2;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Calender {

    public Date calculateNextDay(Date today) {
        
        Date nextDay 
= null;
        //    TODO  
        //    calculate the next day 
        return nextDay;
    } 

    
/**
     * @param args
     */
    public static void main(String[] args) {


        System.out.println("Welcome to the calender program of class CS2003! \n");
        
        BufferedReader in 
= new BufferedReader(new InputStreamReader(System.in));
        String choice = "y";
        
        while
(choice.equals("y")){
            
            
// take the input date from the command line            
            String input = "";
            try {
                System.out.println("Please type the date in the format MM/DD/YYYY");
                System.out.println("or \"n\" to exit the program?");
                input = in.readLine();
            } catch (IOException e) {
                e.printStackTrace();
                continue;
            }

            // user decided to finish        
            if(input.equals("n")) {
                System.out.println("Thank you for using our calender");
                // exit the while loop by using break command                
                break;
            }
            
            
            
//    TODO
            // Create a new Date object with given input
            // Get the next day and display it to the user
                
        
}
        return;
    }

}

 


Date :
Code:

package cs2000
.Lab2;

public class Date {
    public static final double PI = 3.14;
    // field variables    
    private String monthString;
    private int month;
    private int day;
    private int year;

    public Date(int month, int day, int year) {
        super();
        this.month = month;
        this.day = day;
        this.year = year;
    }
    public Date(String date) {
        super();
    
        
//    TODO
        // parse the given string "date"
        // for parsing, you can use StringTokenizer class of JAVA API 
        // then call the other constructor 
        // or set the values of field variables
    }

    
    
// setter/getter methods of the field variables 
    public String getMonthString() {
        return monthString;
    }
    public void setMonthString(String monthString) {
        this.monthString = monthString;
    }
    public int getMonth() {
        return month;
    }
    public void setMonth(int month) {
        this.month = month;
    }
    public int getDay() {
        return day;
    }
    public void setDay(int day) {
        this.day = day;
    }
    public int getYear() {
        return year;
    }
    public void setYear(int year) {
        this.year = year;
    }

    // delegate method toString()
    public String toString() {
        return monthString+" "+day+", "+year;
    }
}

 





Attachments:
Calender.java [1.23 KiB]
Downloaded 933 times
Date.java [1.17 KiB]
Downloaded 892 times
Author:
Newbie
User avatar Posts: 1
Have thanks: 0 time
Post new topic Reply to topic  [ 1 post ] 

  Related Posts  to : Programming Calendar Java
 draw Calendar in java     -  
 java.util Calendar To TimeStamp     -  
 Java Programming help please?     -  
 i want some help in java programming     -  
 Calendar Generator     -  
 Programming a Defragger in Java     -  
 simple javascript calendar     -  
 Java Programming Problem: Pascal's Triangle     -  
 ALP programming     -  
 C++ programming     -  



cron





Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com