How To Perform Action Only If Certain Amount Of Time Passed

Sep 18, 2014

public static void main(String[] args) {
boolean t=false; 
long cuTime = System.currentTimeMillis();
while(t==false) {
System.out.println(cuTime);
long g=cuTime+2000;

[Code] ....

I tried this and it includes a while loop. therefor the whole program has to wait until this while loop executes. So the entire program slows down. Is there any way to do this without a while loop...

View Replies


ADVERTISEMENT

Perform Action Only If Certain Amount Of Time Has Passed

Sep 18, 2014

public static void main(String[] args) {
boolean t=false;
long cuTime = System.currentTimeMillis()
while(t==false) {
System.out.println(cuTime);
long g=cuTime+2000;

[Code] ....

I tried this and it includes a while loop as the whole program has to wait until this while loop executes. So the entire program slows down. Is there any way to do this without a while loop

View Replies View Related

How To Perform Action Only If Certain Amount Of Time Has Passed

Sep 18, 2014

public static void main(String[] args)
{
boolean t=false;
long cuTime = System.currentTimeMillis();
while(t==false)
{
System.out.println(cuTime);

[code].....

I tried this and it includes a while loop as the whole program has to wait until this while loop executes. So the entire program slows down. Is there any way to do this without a while loop

View Replies View Related

Servlets :: There Is No Action Mapped For Namespace And Action Name Associated

Nov 16, 2014

This is my first servlet program. I wanted to try a web application where "register" user module will be in servlet program.I can access my index.jsp but when I enter values and click submit.

I get "There is no Action mapped for namespace [/] and action name [RegisterUserServlet] associated with context path [/TrainingApplication]. - [unknown location]".

Here's my index.jsp file:

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>

[code]....

I am using apache-tomcat-8.0.14 server.

View Replies View Related

Military Time - Adding Minutes Displaying Correct Time

Feb 9, 2015

I am working on an assignment that I can't seem to figure out the final part to. The program takes in course data such as the time the class starts and how long it lasts. The time is in military time (0000 - 2400)

I need the output time to be the time the class started, plus the length of the class, and displayed in military time.

for example,

Start Time = 0930
Length = 50 minutes
Endtime = 1020

I can't for the life of me figure out how to do this. I have gotten a program that works for this time and minutes, and displays the correct 1020. But when I change the information to say

Start time: 0700
Length = 90 minutes

I get:

Endtime = 90

90 is technically correct, the way the formula is setup, but I need it to display 0900 not 90.

Here is the code that I have. Be easy, I'm still learning, and this is just the file I created to get the formula to work. Also, the verbose in here is just for my own debugging to make sure values should be what I'm expecting them to be.

public class calc
{
public static void main(String[] args) {
double hours, minutes, length;
double temp;
int time = 2400;
hours = time / 100;
System.out.println("Hours are: " + hours);

[Code] ....

View Replies View Related

How To Perform Soft Delete

Feb 25, 2014

how to do soft delete?

View Replies View Related

Converting Military Time To Standard Time?

Jan 29, 2014

I have two classes. time_runner is used for testing my code.

This is what I'm using to test my code:
 
class time_runner
{
 public static void main(String str[]) throws IOException {
 Time time1 = new Time(14, 56);
System.out.println("time1: " + time1);
System.out.println("convert time1 to standard time: " + time1.convert());
System.out.println("time1: " + time1);
System.out.print("increment time1 five times: ");
time1.increment();

[code]....

The two constructors are "Time()", which is the default constructor that sets the time to 1200, and "Time(int h, int m)" Which says If h is between 1 and 23 inclusive, set the hour to h. Otherwise, set the hour to 0. If m is between 0 and 59 inclusive, set the minutes to m. Otherwise, set the minutes to 0. Those are my two constructors that I pretty much have down. The three methods however I'm having trouble with. The "String toString()" Returns the time as a String of length 4. The "String convert()" Returns the time as a String converted from military time to standard time. The "void increment()" Advances the time by one minute.

public class Time {
private int hour;
private int minute;
  public Time(int h, int m) {
if(h > 1 && h < 23)
hour = h;

[code]....

View Replies View Related

String Not Being Passed Into Method?

Oct 20, 2014

The only problem I am having is I cannot get my string plainText to go through the encode and prepareString methods.

Is there something in my methods that is wrong, or is it the way that I am calling them?

What is happening is if I enter "this is a test" as a plainText I am getting the samething back with no changes.

View Replies View Related

Values Are Not Being Passed To Array

Sep 29, 2014

I have this class:

package model;
import java.awt.Color;
import shapes.Oval;
import shapes.Rectangle;
import shapes.Shape;
import java.awt.Container;
import java.lang.reflect.Array;

[Code] .....

And as it is now, the values are not being passed into the shapeArray array. If I "hard code" two shapes into the array in this class, everything works fine later on, but I do not manage to pass values into the array from the createShape() method. I tried several approaches, nothing works.

View Replies View Related

Changing Variables That Are Passed In?

Apr 11, 2014

I'm having some trouble figuring out how to change the value of a variable that is passed into a class. I've tried just changing the variable, I've tried changing it by using the this.variable command, and I've even tried calling the setter class from within the class to change it, but it's still not working right. The first class is the one with Main in it and I just feed it some dummy data:

public class ExamConverter {
public static void main(String[] args) {
// TODO Auto-generated method stub
Age testAge = new Age();
 
[Code] .....

This is the other class to calculate the age the way we do it on psych tests - it might not be mathematically accurate, but it's what all the tables and such for raw to scaled score conversion are based on, so the math needs to be the same as opposed to "accurate" because of some months having 30 or 31 days, etc.

public class Age {
//==================Properties==================
// Variables for the test date and client date of birth
private int TestMonth;
private int TestDay;
private int TestYear;
private int ClientMonth;
private int ClientDay;
private int ClientYear;
 
[Code] ......

Based on this dummy data, the output is:
Test: 5/4/2014
DOB: 5/5/1971
Age Years: 43 Months: 0 Days: 0

However, it should be:
Test: 5/4/2014
DOB: 5/5/1971
Age Years: 42 Months: 11 Days: 29

View Replies View Related

Objects Being Passed As Parameters

Aug 7, 2014

If I have a method that takes an ArrayList of a class called Piece and it uses the setPosition() method from Piece. It is changing the value of the array that I passed in, but I want the ArrayList to stay the same outside of the method. Is there any way I can change only the values on the inside of the method, but keep the same position values outside the method?Here is an example.

Piece class
Java Code: public class Piece {
private int xCoor;
private int yCoor;

[code]....

View Replies View Related

While Loop To Perform Multiple Steps

Mar 20, 2014

Write a program that uses a while loop to perform the following steps: Comment by labelling each part: //Part A, //Part B, etc...

A.)Prompt the user to input 2 integers: firstNum and secondNum. Use 10 and 20.
B.)Output all odd numbers between firstNum and secondNum.
C.)Output the sum of all even numbers between firstNum and secondNum.
D.)Output the numbers and their square between 1 and 10.
E.)Output the sum of the square of odd numbers between firstNum and secondNum.
F.)Output all uppercase letters.

Again I am new to while loops and I am totally lost. I have just completed 8 other programs using if else statements and now trying to get the hang of loops.

import java.util.Scanner;
public class whileLoop {
public static void main(String[] args)

[code]...

View Replies View Related

Write A Method That Uses For-loop To Perform?

May 19, 2014

which when user enter a number then will display how many * in a line .Produce a line: ***** But my code only show 1 * there... what wrong with it ?

import java.util.Scanner;
public class display {
public static void main(String args[]) {
int i,n = 0 ;

[Code] ...

View Replies View Related

How To Get One JButton To Perform Sequential Actions

Aug 18, 2014

How to get my program to display a piece of text (upside down) on the first button press, and then display it right-side up on the second button press. I've looked all over the internet and I can't seem to find a example that fits my situation.

Here is the code:

package org.CIS407.Lab10;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class JUpsideDown extends JFrame
implements ActionListener

[Code] ....

View Replies View Related

How To Perform Calculations Using Stacks Java

Nov 23, 2014

I am doing a calculator using stacks but when i try to calculate I getting the wrong data example stack contains 8 and user enter -3 stack should change to 5.

package comp10152.lab5;
import java.util.Scanner;
import java.util.Stack;

[Code].....

View Replies View Related

Alternative To Update Passed Arguments?

Apr 22, 2015

I am writing a simple program in Java, where I call a method and pass some variables (namely, min and max) as arguments. This method is recursive, so the same arguments are again passed on in each recursive call.

I need to update these variables in recursive calls so that when the calling method uses them, it uses updated values. As it might sound confusing, here is sample code :

// Function 1.
void func1() {
//Call func2.
func2 (int hd, int min, int max, Map<String, String> map);
//Other stuff.
}
// Function 2.

[code]....

As you can see, min and max are updated after each recursive call returns, based on conditions. However, these changes aren't reflected in original min and max, which were used by func1 while calling func2. As far as I know, this happens due to call by value mechanism being used by Java while passing arguments. If I declare min and max as instance variables in the class, my problem is solved. But, I want to know whether there's any other way to update these variables so that changes in original min and max are reflected. Yes, I can return them as an array of 2 elements each time while returning, but it didn't seem a good solution to me.

View Replies View Related

Servlets :: Big Form Data Passed

May 29, 2014

I have an html form with 200 input fields of type text. The first input field contains the name of a book author and the remaining 199 fields hold each a title of a book that he or she has written. I also have a servlet that processes the form data and sends it to a file. The entered data is restricted to a combination of the characters "a...z A...Z". how do i go about with creating my html page. The input fields are just too many, how to retrieve the 200 values in servlet.

<html>
<head>
<script>
var k;
function testField(Expression){
k=1;
var str1="abcdefghijklmnopqrstuvwxyz ";
var sor=Expression;

[code]....

View Replies View Related

How To Call On Arraylist That Is Passed In By A Method

Oct 11, 2014

my arraylist is declared in my main method. A string that i will be calling on is declared in my main method as well. The arraylist and string is passed to a method outside the main. I am to search for the beginning of a string and end of the string, remove those items. Then i am to pass the string with the removed items to arraylist that is called in my main with an enhanced for loop. The for loop then displays what is needed from the string and the method i created. I will posting an example of my main and method that is used in my program.

public class ExampleUrl {
public static void main(String[] args) throws MalformedURLException, IOException {
ArrayList<String> urlList = new ArrayList();
String url = "";

[Code].....

View Replies View Related

JSF :: Reference Variable Passed To A File

Sep 30, 2014

How are methods invoked on the `bird` parameter?

next.xhtml:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core">

[Code] ....

`MyQueueBean` is intended to give out a bird once only, to exactly one end-user. Because it's application scoped, and not session scoped, getting attributes directly from the bean would give inconsistent results.

The birds application is from Facelets Essentials Guide to JavaServer Faces View Definition Framework: [URL] ....

how is the variable passed to the file? Once it's passed, how is it referenced?

View Replies View Related

How Does Scanner Goes Through String Which Is Passed To It As Parameter

Feb 7, 2015

How does the Scanner goes through the String which is passed to it as a parameter. For example, String input = "222 dddd 222 ddd22" is passed to the method and here's the code:

Java Code:

public static void sum(String anything)
{
Scanner input = new Scanner(anything)
while(input.hasNext())
{
if(input.hasNextDouble())
{
double nextNumber = inut.nextDouble();
sum += nextNumber
}
......
......
} mh_sh_highlight_all('java');
{

So, how does Scanner calculates a passed String? I just want to know the way it calculates/reads.

View Replies View Related

Any Limit On How Many Parameters Can Be Passed With PreparedStatement?

Mar 31, 2014

I tried to Google, but was not able to find anything relevant.

I have a sql query where in I am using preparedStatement which goes something like :

select * from test where parameters in ( ?,?,?,?,?,?,?,?,?,?,?,?,?);

Is there a limit on how many "?" characters i.e. parameters can be there in this query?

View Replies View Related

How To Perform Tasks Listed In Text File

Feb 12, 2015

This has three different classes in a package and the program itself is supposed to read and perform operations obtained from a txt file. However, I'm not even sure how to get it to perform the operations from the text file. I know that it can read the file as I was able to get the program to print the text found in the file when I ran the program with a test print to make sure that all content was being read. However, I am clueless when it comes to how to get the program to look at the text as commands.

Here is the piece of code that I am not sure where to go from as far as telling the program to read the text and perform the tasks listed.

public static void doTVoperations(){
File operations = new File("operations.txt");
if(operations.exists())
try{
Scanner n = new Scanner(operations);

[Code] ....

View Replies View Related

How To Perform Row Operation - Store Data Into 2D Matrix

Sep 18, 2014

I am able to perform column operation but not able to perform row operation because i am not able to store data say a 2 matrix [][]. I need to store the data into a 2-D matrix. Here is my code:

Java Code:

import java.awt.List;
import java.io.BufferedReader;
import java.io.FileReader;
import java.util.ArrayList;
import java.util.Scanner;
public class colRowRead {

[Code] ....

I tried something like that:

for(int i=0; i<rows; i++) {
for(int j=0; j<cols; j++){
matrix [i][j]=textFile.get(i).split(" ");
//System.out.println(matrix[i][j]);
}
}
*/ mh_sh_highlight_all('java');

File col.txt is like this:

Java Code:
5 9 7 1 5
3 6 8 6 8
4 6 7 8 9
9 8 3 5 7 mh_sh_highlight_all('java');

View Replies View Related

Automated Web Browser To Perform Specific Tasks

Jul 14, 2014

I need to know how to automate a web browser (either Chrome, Firefox or Safari) to perform the following task.

Take a word from a .txt file housed on my hard drive,

1) put it into a search engine,
2) load the results,
3) click on/ open the first result,
4) open up an new tab and perform steps 1-3 again but with the next word from the .txt file. 4-5 second pauses are needed in between each step.

Additionally, I would like to automate the browser to close all the open tabs when a full stop is pulled from the .txt file.

I am using a macbook and 10.6.8 OS.

View Replies View Related

Generate Conditions To Perform Calculations On Whole Numbers?

Dec 12, 2014

I have to ask the user to enter 4 whole numbers, and then the program will calculate:

> x numbers are positive and even
> x numbers are positive and odd
> x numbers are negative and even
> x numbers are negative and odd

but I have trouble with the conditions. How do I form the conditions to calculate this? My professor said I can do this with only four IFs (or ELSE IF). This is what I did:

import java.util.Scanner;
public class Calc{
public static void main(String [] args){
Scanner sc = new Scanner(System.in);
 
int pe = 0, po = 0, ne = 0, no = 0;
/* four variables for each result
pe - positive even
po - positive odd
ne - negative even
no - negative odd

[Code[ ....

View Replies View Related

JavaFX 2.0 :: Perform Boolean Operations On 3D Primitives?

Nov 10, 2014

How to perform boolean operations (union, intersect and subtract) on 3D primitives in javafx 3D?

View Replies View Related







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