Countdown Clock - User Can Input The Time?

Nov 5, 2014

how can you add a feature where the user can input the time for the clock to countdown to?

View Replies


ADVERTISEMENT

Elevator Simulation In Event Time Not Clock

Apr 10, 2014

I am making a elevator simulator for my class. It needs to be "event time". I am having trouble understanding how I can make an "event time" simulator. Initially I was using a while loop to run a clock time simulation of x seconds for each event, until I ran into a concrete wall and had to call another method which took X seconds, while still needing to execute code.

An example of what I did is:

Spawn person -> person.goToElevator (Takes x seconds) - > person.waitForElevator (Until elevator arrives, x seconds). While this is happening, I needed to create another person and do the same thing, this will add another to the queue if the first person is still waiting. Etc etc, you get the point.

We have not learnt about multi threading, that is the next assignment.

Here is a quote from my lecturer:

"That's right, it requires multi-threading which we're not doing in this paper. Here's a solution that can work:

The person waiting for the lift and then doing lots of other things should do all that in a fraction of a second. So, you don't let the person really wait. Instead, you will set a timestamp in the future in the person object that "he's busy till that time". In all other steps in your simulation you will first check if a person is "busy" (i.e. has a timestamp in the future). If so, you can't use this object, otherwise, you can.

How does it create a bigger queue? Outputs I would have in my final simulation would be, averageQueueLength, numOfPeopleInBuilding etc.

View Replies View Related

Creating A Clock That Displays Different TIME In Different Capitals

Oct 16, 2014

As much as a clock and a calender have to do with date and time, a question arose.

I am creating a clock that displays different TIME in different captials.

Date timestamp = new Date();
timestamp.setTime(timestamp.getTime());
DateFormat time = new SimpleDateFormat("HH:mm:ss");
time.setTimeZone(TimeZone.getTimeZone("UTC"));
System.out.println(time.format(timestamp));

This code, returns the current time in UTC 00:00, the center of the time measuring system. And my program either ADDS an hour to the timestamp or deletes an hour, to make it earlier. My question is: Does Java account for Daylight Savings Time?

On that day, hours shift, and does java shift with them? Is there a changed need to make my code in order to not get the wrong results after the daylight savings time has hit?

View Replies View Related

Analog Clock - How To Use Menu To Change Alarm Time

May 10, 2014

the analog clock dese not move put it work when i run the program and the the buttoms dose not work i do not why how i can use the menu alarm to change the alarm time this my code run it.

import java.awt.event.*;
import java.awt.*;
import javax.swing.*;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.swing.Timer;

[code]....

View Replies View Related

Report Employee Time Clock Cannot Find Corresponding Dates In And Out

Mar 8, 2014

I have this assignment to build an employee time clock. By using a menu you can enter an employee, enter punch in and out, and report.When I created the punch screen I wrote the in and out records to a file. Because there can be several employees punching in or out the file wrote each occurrence on different lines. Now I am attempting to write the report which you enter an employee Id and loop through the file to find the in and out date and then calculate the time (hours worked). I loaded the file into an Arraylist but now I cannot figure out how to loop through find the In and Out date - calculate the hours worked and then move on to the next day. here is the format of the file - employee id, place holder I or O, date, time, day. and sample

111221111i3/2/145:10 PMSunday
111221111o3/2/145:10 PMSunday
111331111i3/2/145:25 PMSunday
111331111o3/3/1412:47 PMMonday
111221111i3/3/1412:48 PMMonday
111221111o3/3/142:23 PMMonday
111441111i3/4/141:30 PMTuesday

[code]....

here is my code from the main screen.

public static void displayPunches()
throws FileNotFoundException, IOException, ParseException {
boolean isValid = false;
String choice = "y";
String emp = Validator.getLine(sc, "Enter I -Individual or A -All ");
if (emp.equalsIgnoreCase("A"))

[code]....

View Replies View Related

Getting User Input Second Time

Apr 19, 2014

I'm working on creating a dice game and getting the users input is giving me a really hard time. I have the main game working but this part I'm stuck on. The problem is that it's not giving me the chance to enter the second input when I ask for the game.

//Create Scanner object
Scanner keys = new Scanner(System.in);
//Get chips
System.out.print("How much money would you like to change? ");
int chips = keys.nextInt();
System.out.println("You now have $" + chips + " in chips.");

[code]...

This is what I get when I run it run/How much money would you like to change?

View Replies View Related

Java Program That Will Ask A User To Input Grades Until User Inputs Sentinel Value

Apr 9, 2014

Write a java program that will ask a user to input grades until the user inputs the sentinel value -1. The program should test each input to determine whether 0<=grade<=100. If the grade entered is within this range, the program should print "Grade accepted;" if not, the program should print "Invalid input".

View Replies View Related

Program That Takes User Odd Number And Print Prime Numbers Lower Than User Input

Nov 4, 2014

I have been struggling with this program for weeks. This program is supposed to take a user's inputted odd number and then print out all prime numbers lower than that number.

public class PrimeNumber
{
Scanner scan = new Scanner(System.in);
int userNum;
String neg;

public void getUserNum()

[code]...

View Replies View Related

Create A Countdown In Java

Feb 24, 2014

I'm making a small play in java in which you have a limited time to make as many moves as possible (with the aim of achieving a maximum score), like this: URL...

In the game panel I see the map on which you will perform the moves and a score indicator constantly updated. I have to add the indicator that shows me the passage of time (first 3 minutes), in digital format mm: ss. I thought I will be a useful thread called Countdown because I have to stop this counter if the user presses the pause button in the game. Then wanting to continue the game shall resume the countdown.

View Replies View Related

Time Input Validation

Nov 24, 2014

I am trying to validate user input of time. It seems that only part of it works. It will only accept hour 20-23 as valid.

void timeValidate() {
String value = "";
boolean bTryAgain = true;
Scanner sc = new Scanner(System.in);

[Code] .....

View Replies View Related

Where To Input Segment To Get User Input Dialog

Apr 9, 2015

Where do I input this segment?

Scanner user_input = new Scanner( System.in );// This line goes at the top with the other global variables

public void getUserInput(){
System.out.print("Enter litres: ");
litres = user_input.nextDouble( );
System.out.print("Enter mileage: ");
mileage = user_input.nextDouble( );
System.out.print("Enter speed: ");
speed = user_input.nextDouble( );

[Code] ....

This is my client file.

class Client{
public static void main(String []args){
Bike R1=new Bike(5.0, 60.0,30.0);//create bike object with params
Bike R2=new Bike();//without params
System.out.println(R1.increaseSpeed());//calling methods
System.out.println(R1.maxDistance());
System.out.println(R2.increaseSpeed());
System.out.println(R2.maxDistance());
}
}

View Replies View Related

Countdown Timer - Minutes Class

Dec 10, 2014

I have this code for a Countdown Timer...

Java Code:

package javaproject;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import Countdown.Timer;
import java.util.Timer;
import javaproject.Countdown;
public class Minutes {

[Code] ....

Do I need to put more code in the Countdown class or in the Minutes Class...

View Replies View Related

How To Creat TextTochange Div With Countdown Timer

Feb 12, 2015

im not familiar with Javascript..i need a simple code for text to change with countdown timer and fade in/out effect for the text..i have a code but not with the counter or the effect

<div id="myDiv1">

please wait for a while your link will appear in (i want put here the countdown timer 30 sec)

</div>
<script type="text/javascript">
window.onload = function () {
setTimeout(function () {
var div = document.getElementById('myDiv1');
div.innerHTML = '<a href="the link">click here to get your link</a>';
}, 30000);
}
</script>

View Replies View Related

Java Minutes Program - Countdown Timer

Dec 1, 2014

I'm trying to put in a countdown timer into my project, but want to get it working first. I am finding trouble because I have a couple of errors.

Java Code:

package Project;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class Minutes {
int count = 30; //Integer count is set equal to 30.
int delay = 1000; // Integer delay is equal to 1000. 1000 being in milliseconds which is 1 second.

[Code] .....

View Replies View Related

Time - Cannot Input Any Value Into Parameter Without It Returning Error

Nov 25, 2014

I think my code is correct, but I cannot input any value into the parameter without it returning an error. I have tried different forms of the time (0734, 7:34, 7,34, and others) but none of them work. I attached a screenshot of the error message. How can I input the parameter?

public class Time extends Object
{
private int itsHour; // always in the range 0 to 23
private int itsMin; // always in the range 0 to 59 
/** Create an object for the given hour and minute. If min
* is negative, adjust the values to make 0 <= min < 60. */
 
public Time (int hour, int min) // constructor

[Code] ......

View Replies View Related

Servlets :: Restrict User To Login From One System At A Time

Apr 23, 2014

In My application I want to implement functionality to let user login from only one system at a time. I am searching for something that can Identify the system uniquely (Like IP address or Mac address ). I am using servlet and I don't know how to access Mac in servelt

View Replies View Related

How To Make Shapes Move At Same Time When User Enter Up

Oct 1, 2014

How to make shapes move at same time when user enter up it should move up. It works for rectangle but i don't know how to move the others like that. (btw i am new to java). How can i do that?

import javax.swing.JFrame;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Rectangle;
import javax.swing.JComponent;
import java.awt.geom.Ellipse2D;

[Code] .....

View Replies View Related

How To Create New Customer Object Each Time User Chooses 1 As Option

Feb 17, 2015

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Scanner;

public class App {
public static void main(String[] args) throws IOException {
Scanner keyboard = new Scanner(System.in);
System.out.println("Please Select an option > ");

[Code] .....

View Replies View Related

CountDigitx - Take Two Integers As Input And Return How Many Time X Occurs In Number N

Apr 29, 2014

Write a recursive Java method countDigitx that takes two integer numbers as input (a number n and digit x) and returns the number of times digits x occurs in number n:

For example if n=23242 and x=2 then the method should return 3 that is the number of times the number 2 found in n.

View Replies View Related

Thread And Clock Management

Dec 19, 2014

I have objects (baddies in a game) that have individual clocks/counters assigned to them (when I make an object, I fill an integer based array list with a new digit entry at a value of one) that all happens in threads. then in another thread, I am checking the whole list of clocks, to see if any are equal to a wanted value , then I am taking an action and reseting the clock at that point on the array list.

now, the problem is:even though my code says " yes, I've taken that action because the value of array position x was >= specified value and I will now reset the clock" it doesn't reset the clock. Here is what it looks like

*these are excerpts taken from a really big program, however they should stand on their own as they are individual classes

Java Code:

public class levelclock extends Thread {
public void run() {
while (Run2 == true) {
if (Run == false) {
try {
Thread.sleep(100);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();

[code]....

(Attached, just open up the zip and read the .txt)

View Replies View Related

How To Implement Clock / Timer In Java

Jun 10, 2015

How do I impliment a clock/timer in Java? The program saves files in memory for future use. I've included part of the program below I'd like to add a timer to check if the file was changed every 10 minutes. I have included part of the program below.
 
static FastDateFormat fastDateFormat = FastDateFormat.getInstance("MM/dd/yy HH:mm:ss"); 
  private static final class FileContentsObject {
  private long cachedTime; // currentTime
  private long lastModifiedTimestamp;
  private List<String> contents;

[Code] .....

View Replies View Related

Creating Analog Clock Based On Certain Values

May 3, 2014

I'm working on a Java/Android program that takes a number input (for example, hour = 7 and minutes = 30 for 7:30AM), and then expresses it on an Analog clock. (hour hand pointing to 7 and minute hand pointing to 30 minutes) ...

How can this be done? Would I need a lot of image files? How to start ...

View Replies View Related

Swing/AWT/SWT :: Analog Clock Working But Seconds Repeating In Java

Oct 6, 2014

I made an Analog Clock and its working but when a remove the filloval (Background) the seconds hand keep repeating itself..here is the code

import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import javax.swing.JFrame;
import javax.swing.JPanel;

[code]....

View Replies View Related

How To Get User Input

Nov 13, 2014

I have been coding in my class at school (Grade 11 Computer science) and i just downloaded the program on my computer at home, unfortunately i cannot access my computer notes at home and i also dont remember certian specifics of coding, so my question is how would i get user input to create a program. The comments are the parts i dont remember. (I am trying to slowly build my memory with this stuff)

Here is my code so far:

import java.util;
[highlight=java]
public class hello_world {
public static void main(String[] args) {
string name;
//WHAT DO I PUT HERE????

[code]....

View Replies View Related

Asking User For Input Twice?

Apr 19, 2014

I'm working on creating a dice game and getting the users input is giving me a really hard time. I have the main game working but this part I'm stuck on. The problem is that it's not giving me the chance to enter the second input when I ask for the game.

//Create Scanner object
Scanner keys = new Scanner(System.in);
//Get chips

[Code]....

*****This is what I get when I run it

run:

How much money would you like to change? 50

You now have $50 in chips.

What game do you want to play? You did not pick dice.

View Replies View Related

Can Control User Input

Oct 11, 2014

Is there a way you can control user input?

For example, is it possible to only allow the user to enter digits?

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved