I need a list of all the dates in 2014 in "YYYY-MM-DD" format (because I need to load them into a database), and I do not want to type them all myself. So is there a way to actually get it generated automatically?
I am trying to get random shapes to generate automatically. I was able to get just three shapes to generate but nothing random. When I added the random code now only the frame shows up and no shapes. I also keep getting an error with frame.setVisible(true). It says identifier expected. Here is what I have so far:
Main program:
import javax.swing.*; import java.awt.*; import java.util.Random; public class ShapeGen { public static void main(String [] args) { //Create window and set title draw panel = new Draw();
[Code] ....
This is the draw program to generate random shapes:
import javax.swing.*; import java.awt.*; import java.util.Random; public class draw extends JPanel { public draw(Color backColor) { setBackground(backColor);
how does the program know to calculate for only one year?
public class Interest2 { public static void main(String[] args) { double principal; // The value of the investment. double rate; // The annual interest rate. double interest; // The interest earned during the year.
figuring out the logic to print the day number of the year. The directions for my homework are: Write a program that prints the day number of the year, given the date is in the form: month day year. For example, if the input is 1 1 05, the day number is 1; if the input is 12 25 05, the day number is 359. The program should check for a leap year . I have a basic outline of the program but i am having trouble with figuring out the logic to display the day number of the year given the date. This is what i have so far
import javax.swing.JOptionPane; public class Practice4 { public static void main(String[] args){ String monthStr; String dayStr; int inputMonth;
I'm doing a problem where I convert users input for the date (MM/DD/YY) into a written out date and year. That part is fine. The part I'm struggling with is then indicating what day that is in that year. how to use the user inputted MONTH, DAY, and YEAR to then get the day of year.
import java.util.Calendar; import java.util.Scanner; import java.util.regex.MatchResult; import javax.swing.JOptionPane; public class ConvertDate {
I am doing an assignment for my class and I wish to know if there is anything I did wrong or what would make it easier to read, the assignment is to make a program to check if a year (the user provides the year) is a leap year.
import java.util.*; public class Assignment1 { public static void main(String[] args) { int year; System.out.println("Please enter a year.");
I'm working on a program that prompts the user to enter the year and first day of the year and displays the calendar table for that year on the console. For example, if the user entered the year 2005, and 6 for Saturday, Juanuary,1, 2005, the program should then display the calendar for each month of the year.
I have written the program and solved the problem for the most part. Only, I'm having terrific difficulty getting the output to properly format. I'm *almost* there. I'll post my program below and then output.
import java.util.Scanner; public class DisplayCalendar { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); System.out.print("Enter the year: "); int year = scanner.nextInt();
import java.util.Scanner; import java.io.*; public class LeapYear { public static void main(String[] args) throws IOException { int month1, day1, year1, month2, day2, year2;
[Code] ....
This is the compile error I'm getting:
The total number of days between the dates you entered are: 76882 Exception in thread "main" java.util.InputMismatchException at java.util.Scanner.throwFor(Scanner.java:909) at java.util.Scanner.next(Scanner.java:1530) at java.util.Scanner.nextInt(Scanner.java:2160) at java.util.Scanner.nextInt(Scanner.java:2119) at LeapYear.main(LeapYear.java:16)
This assignment uses the following description to implement a Dialog class for the Leap Year Problem. We need to decompose this problem into 2 classes:
1.The Date.java class: is a public class that represents a date composed of a month , day, and a year. So you need to declare month, day, and year as integers. Date has 1 constructor and 4 methods. Write the constructor for Date which has 3 parameters: int m, int d, int y ; (As an example of a constructor with 2 parameters for example chapter 3 page 152 code listing 3-13 has a perfect example for you to use which is the BankAccount.java.) and the 4 methods:
"dayIs()" which returns a day. It has no parameter. "monthIs()" which returns a month. It has no parameter. "yearIs()" which returns a year. It has not parameter. "isLeapYear()" which returns a boolean value.
"isLeapYear()" has one parameter year and returns a boolean. Write the method isLeapYear() knowing that a year is defined to be a leapyear it is a multiple of 4, and if it is is a multiple of 100, it must also be a multiple of 400. isLeapYear() thus decides when a year is a leap year. (see the discussion on "Hints for Assign5" to discover specific examples of a LeapYear).
The purpose of the Date.java is to decide whether a year is a leap year. Here is a definition of when a year is considered a leap year :
-year y1 is a leap year if it is multiple of 4. -year y1 is a leap year if it is a multiple of 100, it must be a multiple of 400. -Otherwise y1 is not a leap year.
2. The DateJDialog.java class: implements the GUI. Please use the Dialog boxes developed in the book in chapter2 in pages 99-100 in the code-listing 2-32 (NamesDialog.java) for input and output.
Remember that you will prompt the user to enter: -a month; -a day; -a year
And out of these 3 you will be able to create a Date. Then you will use the dialog box to tell the user whether the year entered was a leapyear or not a leapyear.
Remember that we defined in 1- what it means a year is a leap year or not a leap year.
Do not forget to compile the 2 java files. To verify that the DateJDialog.java works, in TextPad after you compile DateJDialog.java, Click on Tools, Click on "Run Java Application".
When you have completed the assignment, please remember to submit Date.java and DateJDialog.java.
I Have been playing with this for while, and I can not seem to get my head around, how I can do this. I need to get the last two digits of a year that a user will enter. For example, a date like July 2 , 2014, I want to get the last two digits of year 2014 which are "14" and divide it by 4. This will give me 3.5; how ever I will disregard the ".5" and just keep the 14. I have no problem doing the division, my biggest this is how to just get the last two digits of a year. This is what I have so far, it is basically a template of how I want my program; I just need getting the last 2 digits of a year.
public class DateCalc { public static void main (String[] args) { String month; int day; int year;
[Code] ....
" This will give me 3.5; how ever I will disregard the ".5" and just keep the 14 ". I meant that I just want to keep the 3 from the 3.5 that will be generated when you divide 14 by 4.
I have been tasked with creating an invoice (school assignment). Part of the calculations is creating an interest depending on the amount of days between the current date entered, and invoice date entered (The program prompts the user to enter both the current and invoice dates by asking for the day, month and year).
We are also supposed to set the contructor to a default date of 1/1/1900.. but I don't know how or where to code that.
How to calculate the difference between the CurrentDate and Invoice. I have displayed the dates to the user as follows.
I'm writing a JavaFX desktop app, and would like to make it automatically run after installation, but I'm not sure where to look to make this happen (or even if it's possible?). I have successfully created a .dmg installer using E(fx)clipse & Ant. Are there options I'm overlooking which I can use in the build.xml? or am I looking in the wrong place entirely?
I'm trying to write a program that computes the number of days between two dates. How I can achieve this. I'm quite sure I'm supposed to use the Calendar class.
I know the below code is supposed to format the FormattedTextField but it doesn't seem to do anything to the form (shown in the picture below). I was wanting, when the form loaded: the text field to look something like this
00/00/2014 - 00:00 am
Where the user is able to
- enter datelike information around the symbol separators ( / or : )
- But where the user could not remove these symbol separators
Code:
package datefield; import javax.swing.JFormattedTextField; import javax.swing.text.DateFormatter; public class NewJFrame extends javax.swing.JFrame { public NewJFrame() { initComponents();
I know this has been covered before but none of the answers made sense to me. I'm hoping there is an easy way to do this. I have 2 user inputted strings that I have converted to dates and I just want the difference in days.
My code :
import java.util.Date; import java.text.SimpleDateFormat; import java.util.Scanner; import java.text.ParseException; public class DateTest { /** * @param args the command line arguments */ public static void main(String[] args) throws ParseException {
[Code] ....
Apparently I can't just subtract the dates like I would in VB.
For this program I am calculating the annual costs of 5 office supplies (user input) each with a 5.7% inflation. The user inputs the cost of each object and my program must calculate and display the price of each object each year for 5 years. I already have this part. What I need is how to add the total costs of all 5 supplies per year and display each total cost. Here is the program:
import java.util.Scanner;//Using keyboard to enter data //Start of Class public class OfficeSupplyCalculator { //Start of Method public static void main(String args[]) { Scanner keyboard = new Scanner(System.in); System.out.println("Enter the first item");
[Code] .....
At the moment all I get for the grand total loop is the same number showing up 5 times. I feel like the problem is how I am declaring the grandtotalperyear variable but I'm not sure what is wrong.
I am working on a project where i need to show a year value in a class that extends JSpinner.Its working just fine but when i try to set an alignment value for the editor textfield it all falls apart and i know im missing something really critical here but i can't see or find it all i know is that i can't make a proper reference to the textfield component in the editor i use in the correct way or aproach.
public class JNumberSpinner extends JSpinner { private String actionCommand; private boolean isEnabled; private int startValue; private int columns; private int alignment; private SpinnerNumberModel model; private JSpinner.NumberEditor numEditor; private JFormattedTextField jTxtEditorView;
The array size is fixed improve it to automatically increase the array size by creating a new larger array and copying the contents of the current array into it .I am using a course class and here is the code for the class
public class Course { private String courseName; private int numberOfStudents; private String[] students = new String[100]; public Course(String courseName)
[Code] ....
As you can see I have the array set to size 100, how do i make so it increments each time the user adds a student.
The program shall assign a new employee ID to the employee and display it on the screen.
The employee ID shall be generated by adding 1 to the largest employee ID already in the employee.txt data file.
You can see I've tried variations of identification++ but have not been successful. I've also tried to get the last or the highest identification in the arrayList but have not done that right.
public static void addEmployee() { String firstName = Validator.getString( sc, "Enter First Name: "); String lastName = Validator.getString( sc, "Enter Last Name: "); int identification = 0;
[Code] ....
I also can display all of the employees their identifications and their punches but I cannot narrow it down to searching one employee and displaying information for just the one.
-If the selected value is ‘I’, prompt the user to enter the employee’s ID number. -If ‘I’ is selected the display shall show the employee’s name and ID, list out each day worked in chronological order, the number of hours worked that day and a total number of hours worked in the two week period.
The report shall prompt the user to re-enter an employee ID of it does not exist in the employee file.
private static void displayReports() { System.out.println("Report"); Scanner sc = new Scanner(System.in); String action = " "; while (!action.equalsIgnoreCase("d"))