masijade 1,351 Industrious Poster Team Colleague Featured Poster

What do you mean "refresh onload". That's useless. Do you mean that you don't want the browser, or any proxies in the middle, caching it. So that everytime the page is referenced it must be retrieved anew, rather than simply loaded from cache? If so, look at the expires and no-cache headers and pragmas (google those terms).

masijade 1,351 Industrious Poster Team Colleague Featured Poster
public static void main(String[] args)
{
    String AQC1_UID = "";
    String AQC1_USER_PWD = "";

    public Login(String AQC1_UID,String AQC1_USER_PWD)
    { 
        this.AQC1_UID=AQC1_UID;
        this.AQC1_USER_PWD=AQC1_USER_PWD;
    }
.....

When indented properly, the error becomes obvious. Do you see it?

I believe you meant to close of main as an empty method, but didn't.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

> javaAddict had the write idea

Write? ;-)

Yep. He rote write. ;-)

(He wrote right, of course.)

masijade 1,351 Industrious Poster Team Colleague Featured Poster

javaAddict had the write idea, unfortunately, your variables are doubles, so you can't simply cast the division operations to ints. You can, however, do this in the print statements.

I.E.

System.out.println("Enter purchase amount: " + purchase);
System.out.println("The change is: " + change);
System.out.println("The number of quarters is: " + (int) quarters);
System.out.println("The number of dimes is: " + (int) dimes);
System.out.println("The number of nickels is: " + (int) nickels);
System.out.println("The number of pennies is: " + (int) pennies);

Edit: The better solution, however, is javaAddicts, combined with you changing the quarters, dimes, nickels, and pennies to ints, rather than doubles.

Edit Again: And I see, he mentioned that also, you seemingly, simply didn't do it. Try javaAddicts solution, and if it doesn't work, post your modified code here with the errors.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Yes, you've added a constructor, but have you, anywhere in your code, called

attr[i] = new attribute();
masijade 1,351 Industrious Poster Team Colleague Featured Poster

You've declarred an array (attr) of type attrribute, but the elements of that array, until defined, are null. So, when you attempt to dereference one of those elements (that are currently null) by referencing the "name" attribute you get an NPE. You need to define each element in the array with new attribute() (or whatever constructor you use).

masijade 1,351 Industrious Poster Team Colleague Featured Poster

I don't know what I was thinking of, I meant Long, of course. ;-)

masijade 1,351 Industrious Poster Team Colleague Featured Poster
Float.parseFloat(String value, int radix);

See the API docs.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

So add a method to the object that will allow you to compare it with another value.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Already done in Sun forums, but I'll do it again here.

The compiler will automatically create a default constructor for your class, but only if you don't declare any constructors at all.

Whenever a constructor is called, if that contructor does not contain a call to a specific super class class constructor, then the compiler will automatically add a call to the default constructor of the super class.

Since you created a constructor in EmpData, it has no default constructor.

Since VectorHandler has no constructor, the compiler creates a default constructor, which calls the default constructor of the super class (EmpData). That constructor does not exist, however.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Simply add

EmpData() {}

to your EmpData class for the first error.

For the second error, you are not using Generics and are using JDK 1.5 or later. It's a warning (a note) and it won't stop you compiling the program, but you really should read up on Generics (check out the "New Features" portion of the API docs for JDK 1.5) and use them.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Look at this (from an earlier attempt of yours which is almost right):

//ED e = new ED();
//e = (e)vect.elementAt(0);

Is the item stored in the vector of type "e", or of type "ED", because the type is what you need to cast to, not the variable.

You should, of course, also place this in a loop using the loop counter rather than 0. Then again, you could use the new for loop and not worry about casting or the counter.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

This is the Java, not JavaScript, forum. You see the difference there?

Next time, post in the JavaScript forum, please.

I have already requested th admins move this thread.

masijade 1,351 Industrious Poster Team Colleague Featured Poster
Prylar getPrylar(String prylr){
      for (Prylar pro : prylar)
void skapaPrylar(){

symbol : method skapaPryl()

Notice the spelling.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

This is my whole code, if anyone could spot the problem.Im not sure which line it is but it is an illegal start of expresion "public static void main(String []args){" at the end of the code.
(It is underlined). ^

import java.util.*;
import java.io.*;
import java.lang.*;

class PrylDialog {
   ArrayList<Person> personer=new ArrayList<Person>();

   Scanner scan=new Scanner(System.in);

   String readString(String fraga){
      System.out.print(fraga);
      String str=scan.nextLine();
      return str;
	 }

   int readInt (String fraga){
      for(;;){

	 try{
	    System.out.print(fraga);
	    int x= Integer.parseInt(scan.nextLine());
	    return x;
	 }
	 catch (NumberFormatException e){
	    System.out.println("Fel - skall vara numerisk värde ");
	 }
      }
   }

   Person getPerson(String na){
      for (Person p : personer)
	 if (p.getNamn().equalsIgnoreCase(na))
	    return p;
      return null; 
   }
   Prylar getPrylar(String prylr){
      for (Prylar pro : prylar)
      if (pro.getPrylNamn().equalsIgnoreCase(prylr))
      return pro;
      return null;
      }

    int kommando(){
      for(;;){
	 int option=readInt("\n1 Skapa person\n2 Skapa pryl\n3 Visa alla\n4 Visa rikast\n5 Visa viss person\n6 Börskrasch\n7 Avsluta\n\n Ditt val: ");
	 if (option>=1 && option<=7)
	    return option;
	 else 
	 System.out.println("Felaktig kommando, ska vara 1-7\\n"); 
      }
   }

   void skapaPerson(){
      String namn=readString("Namn: ");;
      if (getPerson(namn)!=null){
	 System.out.println ("Person med namn-"+namn+" finns redan");
	 return;
      }
      Person pers= new Person(namn);
      personer.add(pers);
   }

   void skapaPrylar(){
      String pryl = readString("Vilken sorts pryl: ");
      String namn = readString("Vilken person äger prylen: ");
      Person p=getPerson(namn);
      if (p==null){
	 System.out.println("Det finns inget person som heter "+namn);
	 return;
      }
  
      if (pryl.equalsIgnoreCase("Smycke")){
	 int v=readInt("Vikt: ");
	    int sten=readInt("Antal ädelstenar: ");
	    Smycke sm=new Smycke(pryl, v, sten);
	    getPerson(namn).prylar.add(sm);
  }
         else if (pryl.equalsIgnoreCase("apparater")){
	 int inkop =readInt("Pris: ");
	 int slit=readInt("Värde (1-10): ");
	 if (slit<1 && slit>10)
	    System.out.println("You Wroonnng FOOL!!!");
	 return;
	 Apparater ap= new Apparater(pryl, inkop, slit);
	 getPerson(namn).prylar.add(ap);
       } …
masijade 1,351 Industrious Poster Team Colleague Featured Poster

your

void skapaPrylar(){

method is not closed. add another

}

above the

public static void main ....

line

masijade 1,351 Industrious Poster Team Colleague Featured Poster

you might want to check if the error is in pryDialog() because to me, your code should not give you an error

That error is a compiler error, and as I have said, it is normally triggered by what came before. I.e. the previous method does not have a closing brace (so you then are effectively trying to declare a method within a method) or the last statement is missing the semicolon (which then means that the method declaration is effectively part of the previous statement) are the two main causes of this.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

We need to see what comes directly before the method. That error normally occurrs because you've done something wrong before that, such as not closing a previous method, or forgetting a semicolon on the previous line, etc.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Don't do peoples (home)work for them.

Edit: It doesn't help them, in the least.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

A Calendar object set to the proper year and month and the getActualMaximum method.

See the API doc for Calendar.

Edit:

But, if you want (for whatever reason) to figure it out the "old-fashioned way" then convert the following into a short algorithm.

Feb has 29 days in every year evenly divisible by 4, excpet when the year is also evenly divisble by 100, unless the year is also evenly divisble by 400.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

change from show() to setVisible(true) .... and find a better tutorial, that one's outdated.

iamthwee commented: Damn right! +13
masijade 1,351 Industrious Poster Team Colleague Featured Poster

Umm, peter, I thought you knew this one. ;-)

str = servletData.toString();

I believe should be

str = new String(servletData);

or

str = new String(servletData, charset);

if the "bytes" are neither ascii, nor UTF, nor the local charset.

The second one (with the toByteArray()) is correct, but if its not working then check out the charset variation.

And Merry Christmas and a Happy New Year! (and if you're not Catholic/Christian/Other Derivatives don't take offense). ;-)

peter_budo commented: Great mind +7
masijade 1,351 Industrious Poster Team Colleague Featured Poster
Integer.parseInt("10101", 2);

Does what you said.

Integer.parseInt("ABCDEF", 16);

Parses a hexidecimal number. The second number is the radix (as the argument says). If you use 2, then yes, its binary. If you use 16, then its hex. The radix is "base" you're talking about. Have you tried it in that manner? Seemingly not, or you would not have made that last post. Just because, in whatever example you saw, only 2 for binary was used, does not mean that that is the only "base" that the method understands.

Edit: It does not simply convert a binary String representation of an integer to a String representation of an integer in another base. That is not how it works. It takes whatever String you give it and parses that String into an Integer using the radix you give as the "base" for the String representation in the first argument.

masijade 1,351 Industrious Poster Team Colleague Featured Poster
public class OutlookPanel extends JPanel {
    public OutLookPanel() {
    }
    public OutLookPanel(Layout layout) {
        super(layout);
    }
    public OutLookPanel(boolean isDoubleBuffered) {
        super(isDoubleBuffered);
    }
    public OutLookPanel(Layout layout, boolean isDoubleBuffered) {
        super(layout, isDoubleBuffered);
    }
}
masijade 1,351 Industrious Poster Team Colleague Featured Poster

Please use a few imports. Reading that code with all those explicit calls is painful, and annoying, and I, for one, am definately not going to "fight through it". Use some imports and then repost your code.

And, I will ask again, what is wrong with Integer and its parseInt(string, radix) method? And, to go along with that, Integer and its toString(int, radix) method.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

What's wrong with the Integer class and its varying parseInt() methods?

masijade 1,351 Industrious Poster Team Colleague Featured Poster
masijade 1,351 Industrious Poster Team Colleague Featured Poster

create a object ab using InputBufferedReader method.
....
read() reads a character by character from the input.

If you mean BufferedInputStream then no. It reads byte by byte, which is not necessarily the same thing.

If you mean BufferedReader, ok.

But there is no such thing as an InputBufferedReader (which would have to be a class and not method BTW).

masijade 1,351 Industrious Poster Team Colleague Featured Poster

What part of "No" did you not understand? The "N" or the "o"?

A Java program can be converted to a native executable, however this looses all of the advantages you had from using Java in the first place, and the created native programs are, usually, no where near as efficient (in any aspect) as a normal Java Program. All of this is, of course, a moot point if you are not talking about one you are creating, but rather just something you have downloaded.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

It might help to know what you expect, and what you get, as well as any errors that are occurring. But, thing, if you are passing a boolean already then the == is redundant. Simply do

if (O) {
masijade 1,351 Industrious Poster Team Colleague Featured Poster

Oh, I just noticed too, that I accidentally inserted a \ in front of the first paren.

Although, to tell you the truth, I don't know if yours is truely measurably more effecient (unless the string is very long). I feel it's simply more a personal preference (once again, depending on the length of the string, due to the amount of backtracking).

masijade 1,351 Industrious Poster Team Colleague Featured Poster
s/^\s*\(.+)\s*$/$1/
masijade 1,351 Industrious Poster Team Colleague Featured Poster

Ok, unfortunately, the only thing left to do, that I can think of, is to do the script this way:

#!/bin/sh -f
for i in `grep "/\\*" file`; do
  echo "$i"
done

And start the entire script without file name generation. That means, however, that file name expansion/generation does not work at all in the script, which may be wholly unenjoyable, but at least this part works.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

It is because of file name expansion in the shell.

Just for fun try it this way

for i in `grep "/\\*" file`; do
  set -f i=$i
  echo "$i"
done
masijade 1,351 Industrious Poster Team Colleague Featured Poster
for i in `grep "/\\*" file.c`; do

You need to escape the escape character when doing this inside of the expression quotes.

Edit: Which, I believe, is what ithelp meant, but he mistakenly used /// instead of /\\.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

To tell you the truth, that may seem efficient, however, once returned, the rest of th program must then "parse" that String to extract the info (it won't necessarilly only be used for output), whereas that object will allow the rest of the program to directly access the data without having to parse it first.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Okay, I will try to say this nicely.

Given that the data to be read is 1001,11001, etc and given the text The binary number will be passed in as an array of Booleans (a true represents a 1 and a false represents a 0) it seems faairly obvious that you need to create the binary array yourself. It's a stupid requirement, yes, but that's the way the world is. I've seen requirements much worse in real projects.

Now, maybe it's just me, but that all seems to be glaringly obvious, so your first post said to me (reading between the lines), "write (at least this part of) the program for me". Which was the reason for my first post. I apologize if that was not the case, but that is the way I interpreted the first post (and we get that here so often it has become the norm, rather than the exception).

But, in any case, read in the String, create a boolean array of the same length as the String, then loop over the String setting each element in the array according to the requirements provided in the assignment text. (Really, you only need to worry about the ones, as a boolean array is initiated with all elements false, which is how 0 is to be represented.)

Edit: And a boolean is, yes, a boolean. But, what is a boolean? It is a switch, an "either/or", in other words, which is also exactly …

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Whatever. Continue on in your world of percieved slights. I'm not the one here asking for help.

You know what they say about biting the hand that feeds you.

And, you can prefer anything you wish, not that you can make it come true.

Edit: But, it's fairly obvious that you read in the number anyway you want to, and create the "binary array" from the read string (I assume from that snippet that you read the "number" already in binary format) and pass that array to the method that is to do the conversion. It is kind of hard for your program to receive the input as an array already already (unless it is to read it over a socket using an ObjectIputStream or something, which is beyond the current class objectives, I would assume) so it should also be fairly obvious that you need to create the argument you pass to the array from whatever you read in, reagardless of how you read it in, so, I don't see what has been giving you a problem.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Almost word for word.... thats my issue, I'm confused by the wording of the assignment...

As to it looking like I wanted you to do it for me...

Next time, don't make poor assumptions and you would avoid looking like an idiot?
Don't take your anger out on me because you didn't read the question and are suddenly surprised when someone points that out.

No where in that first post did you give any indication of having done any work. Made a lot of statements about "I thought" "I tried" but didn't show any of that effort, and it's easy to claim. So it was still nothing but a "do my work for me" post. And the only one looking like an idiot is you doing your "I didn't say that" backpedaling.

Everyone keeps mentioning a boolean array, where the heck is it? Or, am I already done and the bit about boolean arrays in the problem wasn't necessary to solving it?

You mentioned the boolean array, here the quote from your first post The binary number will be passed in as an array of Booleans (a true represents a 1 and a false represents a 0.).

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Yes I do know that a boolean array is an array of booleans, but when you said binary array, I wasn't sure if you meant the array of integers, as I've never actually heard of a "binary" array. In the op the text I copy and pasted seems to refer to an array of booleans, while the test data hes provided (http://www.shenet.org/high/hsacaddept/technology/chanley/assigns/2007/Test%20Plan%20for%20Method%20Pract.pdf) here, (problem n, seems to show the input as an int.

He refered to it as a "binary aray" because that is essentially what a boolean array is. Binary is 1 or 0, boolean is true or false. So, in the sense of this homework assignment, that boolean array is a binary array. Each boolean array element is one bit in the binary sequence.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

See that's just a rude comment. I of course actually read the policies, and am well aware that it would not make sense to just give me the answer. Maybe you should take time to consider that not all people on the site are as ignorant of the rules as some. Notice the part where I'm taking AP Comp Sci? Anyone in even the basic Java course could make a good stab at this problem. What I wanted was help understanding what he wanted me to do and what he was talking about in the second sentence.

Here's code to do it using an array of integers.

Tester
case 3:
            System.out.println("Please Input a binary number");
            String ys;     
            ys=sc.next();      
            int [] binary = new int [ys.length()];
            for (int i = 0; i < binary.length; i++) {
              binary[i] = (int)ys.charAt(i)-(int)'0';
            }
            System.out.println("The number in base 10 is " + (mp.binToInt(binary)));
            break;



Method
  //pre: Given a binary number
//post Returns the decimal equivelent of the number as an integer
  public Integer binToInt(int[] binary) {
    int decimal = 0;
    for (int i = binary.length - 1; i > -1; i--) {
      decimal += Math.pow(2, (binary.length - i - 1)) * binary[i];
    }
    return decimal;
  }

And no this is not just a rude comment. You posted your homework assignment, almost word for word it looks like, without giving any indication that you had done anything at all. What is anyone suppossed to infer from that other than "Do my homework for me"? Next time, …

masijade 1,351 Industrious Poster Team Colleague Featured Poster

So, wht do you have so far? We are not going to do your homework for you, that is not only morally wrong, it is against the Daniweb terms and policies, which you agreed to when creating an account here.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Although all you really need to do is look at his moniker to find out what he wants here.

"chetah" when sounded out is the current "slang" sound for cheater. The "street" sound for "er" is, now, almost always "ah".

masijade 1,351 Industrious Poster Team Colleague Featured Poster

You don't compare Strings with either == or != use

while(!"stop".equals(fName)) {

And, before you ask, putting "stop" instead of fName first, avoids a possible NullPointerException if fName happens to be null. That does not mean you won't have problems inside the while if it is null, so you should probably do

while ((fName != null) && (!"stop".equals(fName)) {
masijade 1,351 Industrious Poster Team Colleague Featured Poster

What exactly is the problem? Other than the fact, of course, that the method you're calling returns a value and you are simply ignoring that value, rather than storing it in a variable, evaluating it, then printing either it or the message.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

I would have to assume that it is coming from the tee (and that error will only occur on the file handle being read, not the filehandle being written), so I have to assume that the find command is not finding anything. But that also seems strange, as I believe that should have the same effect as doing

echo "" | tee -a filename

which as far as I know should not produce an error. Are you certain the error is happening here.

That error also occurs when a quoted string is not ended properly in the script so the shell continues reading the script as a part of the quoted string, but reaches the end of the file before reaching the end of the string as follows:

#!/bin/sh
var="this is an unfinished string
cat filename  # never gets executed as the shell still considers this a part of the string above
# here the script ends and produces the error given above as the string is not ended
masijade 1,351 Industrious Poster Team Colleague Featured Poster

then do

find / -wholename='somename' -print | tee -a filename

Edit:

Although I am not familiar with "wholename" argument, I assume your find options are actually something different (and correct).

masijade 1,351 Industrious Poster Team Colleague Featured Poster

As long as the first String is always of the same length and does not vary over the "tabStop index" length. printf (if you're using a late enough version of it) is, of course, the proper way to do this.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Because everyone of your constructors are redefining them.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

No, not just post your code, look a little closer at the OP, and you will see a list of multiple choice questions. He really just wants his entire homework/test done for him. He has no desire to do it himself, at all.

;-)