Why Do-while Loop Isn't Fully Working

Sep 23, 2014

I'm having trouble figuring out why my do-while loop isn't fully working. As you can see, it will loop for the first 2 values of i (1 and 2), but then after that if i doesn't fit in my if or if-else statements, the loop stops.

int iterationNum = 1;
int cycle = 0;
double denominator = 1.0;
double pi = 0.0;
double validPrint;
int n = 1;
do {
pi += (4.0 * Math.pow(-1.0, cycle))/denominator;

[code]....

View Replies


ADVERTISEMENT

Servlets :: Session-timeout Not Fully Working

May 9, 2014

in my web.xml my session time out is working but not fully working in my ui i use tiles , i have 5 clickable side panels i try to set timeout for 1 minute or 10 minutes for testing after the time is timeout this what happen working refresh the page after time out = working ,directed me into log in page which is correct.i have 5 clickable side panel in my page after timeout when i click the first 2 in side panel tabs it directed me into log in page which is also correct not working after the timeout when i navigate the page i click the other 3 side panels i can still navigate into the page but when i click the first 2 side panel it directed to log in page w/c is correct but can still navigate the page the other 3 side panels

issue : my session timeout is not fully working on my page.

<session-config>
<session-timeout>10</session-timeout>
</session-config>

View Replies View Related

Why While Loop Isn't Working

Oct 29, 2014

working on a project but cant seem to get my while loop to restart i want to restart this guessing game if the user inputs y at the end otherwise it will end.

import java.util.Scanner;
import java.util.Random;
public class GuessingGame{
public static void main(String[] args){
Scanner in = new Scanner(System.in);
String again = "y";
while(again=="y"){

[code]....

View Replies View Related

Print Triangle - Loop Is Not Working

Jul 7, 2014

I am trying to make a program that prints triangle... and I did various test on each method to realise that the problem lies with this segment.When I call this method, nothing prints out, I figure there is something with the loop that I am not realizing.the loop is backwards because it's supposed to have the right side edge parralel (when I try to print it out the spaces do not appear, imagine the x are space...), so as each line is looped the # of spaces diminishes

xxxx*
xxx*x*
xx*xx*
x*xxx*
*****

public class test {
public static void main(String[] args){  
for (int countdown = 5; countdown <= 1; countdown = countdown--){
showNTimes(countdown, ' ');
showNTimes(5- countdown, '*');
System.out.println("");
}
}
public static void showNTimes ( int nbTimes, char carac ) {
for ( int i = 1 ; i <= nbTimes ; i = i + 1 ) {
System.out.print( carac );
}
}
}

View Replies View Related

Program Involving For Loop And If Statement Not Working

Oct 23, 2014

Alright so I'm trying to write a code that implements a for loop and if statements that displays any number from 100-200 if the number is divisible by either 5 or 6 in rows of ten numbers each row. If it is not divisible by that number then it should go back to the beginning of the loop until it reaches 200. My main problem is that it doesn't display anything. I don't get any errors or anything but every time I run the program it just displays nothing. Sample output is at the bottom of the code.
 
public class Exercise5_11 {
public static void main(String[] args) {
int count = 0;
int i = 100; 
//for (the numbers from 100 to 200)
for (i = 100; i>100 && i<200; i++){
 
[Code] ....

/*Output
100 102 105 108 110 114 115 125 126 130
132 135 138 140 144 145 155 156 160 162
165 168 170 174 175 185 186 190 192 195
198 200
*/

It is still wip of course so I was trying to just get it to display int i but it doesn't do anything and I'm not really sure why.

View Replies View Related

Adding Stars After Each Item In The List - For Loop Isn't Working?

Feb 26, 2014

This is supposed to be a method that adds stars after each item in the list.

Java Code:

import java.util.ArrayList;
public class ClientProgram {
public static void main(String[] args) {
ArrayList<String> list = new ArrayList<String>();
list.add("the");

[Code] ...

I'm guessing it's because list.size() changes, though but it should only find that value in the beginning, so it shouldn't be a problem?

View Replies View Related

JavaFX 2.0 :: UI Not Fully Updated After Transitions (only On Linux)

Feb 27, 2015

After a transition of an object  the UI is not fully updated. One can still see "lines" from the "movement". This only happens on Linux (Debian) and not on Windows. Is this a known issue that has been fixed in later Javafx releases ? I am still using Java7 because of WinXP support

View Replies View Related

How To Make All Shapes Fully Stay Within Frame Border

Feb 16, 2014

I have a problem with a shape generator. It randoms the shapes just fine, I just do not know how to make all the shapes fully stay within the frames border.

RandomShapeMaker.java

import java.awt.Color;
import java.awt.Graphics;
import javax.swing.JPanel;
import java.util.Random;
public class RandomShapeMaker extends JPanel{
private static final Random randomShape = new Random();
public void paintComponent( Graphics g ){
super.paintComponent( g );

[Code] ....

View Replies View Related

JSP :: Navigation System Putting Two Headers In HTML File When Fully Rendered In Browser

Oct 21, 2014

I inherited a navigation system which is like this:

index.jsp
homepage.jsp

When I click on the "view source" in the browser, I get two headers like this:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en_US">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<meta http-equiv="X-UA-Compatible" content="IE=edge">

[Code] ....

I know this is not good. I have inherited the nav system from someone else and I have a lot of complicated AJAX and JQuery going on inside my module. I am not sure how to resolve.

View Replies View Related

Project Is Working On JFrame - But Not Working On JApplet

Apr 10, 2014

I am developing an application to share my client screen with server, it is working well on swing. But i want to develop as web application, i am trying to using applet. But i am facing the fallowing problem..,

1) The Applet screen also open and project also running well on server mechine. But unable to see the client screen on the server.

2) The problem may be to display the JDesktopPane or JInternalFrame.

My working Server Code extends withe JFrame..Java Code:

package remoteserver;
import java.awt.BorderLayout;
import java.awt.Container;
import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import javax.swing.JApplet;
import javax.swing.JDesktopPane;
import javax.swing.JFrame;
import javax.swing.JOptionPane;

[code]....

View Replies View Related

Unable To Print A Loop Inside Array Of Greater Size Than Loop Itself

Jan 27, 2015

I am trying to print a loop inside an array of a greater size than the loop itself. Like for example I have an array of size 7 but it has only 3 elements.

int[] array=new int[7]
array[0]=2;
array[1]=3;
array[2]=4;

now what I want to do is print these three numbers in a loop so that my array[3]=2;array[4]=3;array[5]=4 ...... till the last one. Also the array could be any size and not just 7.

View Replies View Related

While Loop Inside A For Loop To Determine Proper Length Of Variable

Feb 25, 2014

Here's the code: it's while loop inside a for loop to determine the proper length of a variable:

for (int i = 0; i < num; i++) {
horse[i]=new thoroughbred();
boolean propernamelength = false;
while (propernamelength==false){
String name = entry.getUserInput("Enter the name of horse "

[code]....

I was just wondering what was going on here -- I've initialized the variable, so why do I get this message? (actually the carat was under the variable name inside the parentheses.

View Replies View Related

When Type Quit To Close Outer Loop / It Still Runs Inner Loop

Nov 2, 2014

I have everything else working. My problem is that when i type "quit" to close the outer loop. It still runs the inner loop. The National Bank manager wants you to code a program that reads each clients charges to their Credit Card account and outputs the average charge per client and the overall average for the total number of clients in the Bank.

Hint: The OUTER LOOP in your program should allow the user the name of the client and end the program when the name entered is QUIT.In addition to the outer loop, you need AN INNER LOOP that will allow the user to input the clients charge to his/her account by entering one charge at a time and end inputting the charges whenever she/he enters -1 for a value. This INNER LOOP will performed the Add for all the charges entered for a client and count the number of charges entered.

After INNER LOOP ends, the program calculates an average for this student. The average is calculated by dividing the Total into the number of charges entered. The program prints the average charge for that client, adds the Total to a GrandTotal, assigns zero to the Total and counter variables before it loops back to get the grade for another client.Use DecimalFormat or NumberFormat to format the numeric output to dollar amounts.

The output of the program should something like this:

John Smith average $850.00
Maria Gonzalez average $90.67
Terry Lucas average $959.00
Mickey Mouse course average $6,050.89
National Bank client average $1,987.67

Code:

public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
String name = "";
int charge = 0;
int count = -1;
int total = 1;
int grandtotal = 0;
int average = 0;
 
[code]....

View Replies View Related

Convert From While Loop To For Loop

Mar 8, 2014

How to convert this program from a while loop to a for loop.

import java.util.Scanner;
public class LongDivision {
public static void main(String arguments[]){
Scanner input = new Scanner(System.in);
System.out.println("Enter the dividend: ");

[Code] ....

View Replies View Related

Converting For Loop To While And Do While Loop

Feb 17, 2014

How do I convert my for loop below to a while and do while loop?

for(int a=1;a<=9;a++){
for(int b=1;b<=a;b++){
System.out.print(a);
}
System.out.println();

[Code] .....

View Replies View Related

How To Store Value From Loop To Add To New Value From Loop

Feb 9, 2015

I am trying to make a program add values from a loop. So what its supposed to do is search through tokens on an imported file. The file lists State, Capital, and then capital population. Then take the population string, turn it into numbers, and then do stuff with the numbers. First I'm supposed to find the Highest and lowest population of the places in the file (which I did without problem), but the finally thing is I'm supposed to add each found population to the last so I can find the average of the populations.

I just cannot seem to grasp how to do that. I THINK I'm supposed to some how store the given value into a variable, but how do I get that variable to add to the new value?

like...?
Get token -> a
b = a
c = a + b

or wait no.....

Java Code :

import java.io.*;
import java.util.Scanner;
public class CapPopS
{
public static void main(String[] args) throws IOException
{
File stateCAP = new File("state-capital-2004population.txt");
if (!stateCAP.exists())

[Code] ....

View Replies View Related

Why Key Not Working

Aug 29, 2014

Why in my program keys are not working, what I forgot to write?

import javax.swing.JFrame;
public class Main {
public static void main(String args[]) {
JFrame frame = new JFrame("Stickman");
frame.setDefaultCloseOperation(frame.EXIT_ON_CLOSE);
frame.setSize(450, 490);

[code]....

View Replies View Related

Jar Is Not Working

Mar 5, 2014

I got my code into a jar, but when I run it I get his message:I just used Eclipse to make my jar and I thought I did it right but I guess not.

View Replies View Related

Scanner Is Not Working

Apr 24, 2014

I wrote a piece of code:

for(int i = 0; i < x; i++){
System.out.println("Enter students full name:");
sName[i] = result.fullName(sc.nextLine());
sExam[i] = result.examName("VB");
System.out.println("Enter students exam score:");
int scor = sc.nextInt();
sScore[i] = result.examScore(scor);
sGrade[i] = result.examGrade(scor);
}

When i run it i get:

Enter number of students:
1
Enter students full name:
Enter students exam score:

The problem is, i cant enter "full name", program is just jumping to the next step "exam score".

View Replies View Related

GetColor Is Not Working?

Oct 9, 2014

I am working on a fairly simple program where I have a colour change three times using the red green blue spectrum. The problem is that I keep getting a result of zero no matter what I do.

import java.awt.*;
 class RectangleMain
{
public static void main (String[] args) {
ColouredRectangle blocky = new ColouredRectangle(50, 100, 20, 40, Color.red);
System.out.println(blocky.getColour());
blocky.mixColour(Color.blue);

[code]...

View Replies View Related

KeyListener Is Not Working?

May 31, 2014

I'm programming a game, but the keyListener doesn't work. Here is the source code:

import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
 public class InputHandler implements KeyListener{
 public InputHandler(Game game) {
game.addKeyListener(this);

[code]....

My Question is: Why will it not say "up", if I press "w"?

View Replies View Related

If Statement Not Working?

May 5, 2014

I'm having a problem where an if statement isn't working. In the Person class boolean olderThan ignores my if statement so it always returns false and I just don't get why that's happening.

import java.util.Calendar;
public class Person {
private String name;
private MyDate birthday;
  public Person(String name, int pp, int kk, int vv) {
this.name = name;

[code].....

View Replies View Related

Jar File Is Not Working

Feb 25, 2015

I have added a Simple Jar file in Eclipse Proect->BuildPath->jar file but class Inside that are not showing in My project this is my Project Structure and I have all ready checked in Order and Export..But jar file is not working.

View Replies View Related

MCV - Buttons Not Working?

Sep 7, 2014

I am learning out design patterns and doing a little fun project on Model Control View (MCV). I got the concept down, it is pretty simple for the most part. However my buttons are not working.

Here is the code:

public class Controller
{
private Model model;
private View view;
 Controller(Model model, View view) {
this.model = model;
this.view = view;

[code]....

It runs but nothing. My other questions is how can I make a box that will print the results.

View Replies View Related

Iterator Next Not Working In If

Apr 4, 2014

I need to find out if one array list is a sub-sequence of another. The elements in the first list all need to be in the second list and must be in the same order. So s1<n, t, a> is a sub-sequence of s2<q, n, f, r, t, d, a>, but s1<a, a, t> is not a sub-sequence of s2<a, t, a>. I need to use iterators to go through each list, and I should only go through each list once (since it has to be in the same order) so nested loops don't seem like they would work because it would start at the beginning of one list every time it moved to another element in the outer loop's list.I seem to have an issue where the itr1. next()
is ignored when in an if statement.

My current code just stalls and will never stop running. I've also switched things around and put the not equal check after the if it is equal and it throws a NoSuchElementException.

import dataStructures.*;
public class Subsequence3
{
public static void main(String[] args)
{
ArrayList<Character> s1 = new ArrayList<Character>();
s1.add('n');
s1.add('p');
s1.add('a');

[code]....

View Replies View Related

Jar Not Working As Expected

Feb 2, 2014

the problem which im facing when executing jar file is it is not working same as when i run file using the IDE.When run jar file, it won't open the new frame even the user and pass combination correct.But when i'm compiling using the IDE, it works as charm. The main menu popped up after i logged in.I've tried Clean and Build and it's not working too.

View Replies View Related







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