The error message is:
"Syntax error on token '&&', invalid OnlySynchronize d"
thanks....
User Profile
Collapse
-
Java Matrix
I am making a program that deals with matrices in Java.
I keep getting an error and I don't know how to fix it
my code so far is
[code=java]
import java.io.*;
import java.util.*;
import java.util.Scann er;
public class Matrix {
public float elements[][];
public int numOfCols;
public int numOfRows;
public... -
Thanks a lot for all the advice! I officially got my loop (and my calculator) working! I've stumbled upon a new problem though....how do I assign the result of my calculator to a new variable? For example:
First number: 5
Second number: 9
Operation (+ - / * %): +
The result: 14
Again? (y/n): y
Fist number: _
Second number: 1
Operation (+ - / * %): -
The result: 13
...Leave a comment:
-
Thanks for the article link!
Actually, for my program, if the user chooses to run it again, the input should be 2 brand new numbers, so for example:
Please enter the first number: 6
Please enter the second number: 9
Please enter the operator: +
6 + 9 = 15
Do you want to continue (y/n)? y
Please enter the first number: 4
Please enter the second number: 4
Please enter the operator:...Leave a comment:
-
thanks to everyone for their help, i think i'm slowly getting the hang of it.
I've configured my calculator so that it works as it is supposed to (for the most part), but now I'm trying to add a statement that will continue the process of evaluating the numbers entered should the user choose to continue.
So far, here is my code:
[code=java]
import java.util.Scann er;
public class Calculator...Leave a comment:
-
Thanks for the quick reply...I think I figured that part out...now I'm having a problem adding if statements...I' m trying to say if my operator is equal to '+' then the 2 numbers should be added. Like, I said, I'm very new at this, so I apologize if I make stupid mistakes...this is what I have so far:
[code=java]System.out.prin tln("Enter an operator (+ - * / %): ");
String x= sc.next();
if (x== +)
...Leave a comment:
-
Java Calculator
I have just started using java and I'm trying to make a simple calculator, but I'm confused as to why I keep getting a warning message.
[code=java]import java.util.Scann er;
public class Calculator {
public static void main(String[] args) {
Scanner sc=new Scanner(System. in);
System.out.prin tln("Enter first number: ");
double d1=sc.nextDoubl e();... -
I'm trying to check if the words are in a file though...
does it still not matter then?...Leave a comment:
-
[QUOTE=William Manley]
thanks for the suggestion, however i have an else statement after that elif statement...my else statement tells the user that the word isn't in either dictionary and then asks them if they would like to add it to the user dictionary....Leave a comment:
-
I've encountered yet another problem. I'm trying to get my program to check the dictionary, and then if it isn't in the dictionary, the user dictionary is checked for the word, however my code won't work.
[code=python]word=str(raw_in put("Enter a word: "))
words=[line[:-1] for line in f]
if word in words:
print "The word '%s' is in the dictionary."...Leave a comment:
-
Thank you to everyone for their suggestions and comments, the code seems to work now...
I'll definitely post up any other problems should I have them :)Leave a comment:
-
Thank you for your help!
However, when I implement the code that you've suggested, I don't get a printed statement telling me the word is in my dictionary.
I've tried to walk myself through the code and can't seem to figure out what's going on...Leave a comment:
-
[code=python]>>> f=open("dict.tx t","r")
>>> text=f.read()
>>> 'zygote' in text
True
>>> import re
>>> patt=re.compile ('[a-z]+',re.IGNORECAS E)
>>> 'zygote' in patt.findall(te xt)
True
>>> patt.findall(te xt).index('zygo te')
113789
>>> patt.findall(te xt)[/code]
after that last...Leave a comment:
-
search problem
[code=python]
>>>
>>> f=open("dict.tx t","r")
>>> word='zygote'
>>> for line in f:
if word in line:
print "Your word is in the dictionary"
Your word is in the dictionary
Your word is in the dictionary
Your word is in the dictionary
Your word is in the dictionary[/code]
... -
thanks again to everyone for their help.
i'm encountering a major problem with my project though.
i'm supposed to take the file named dict.txt which has quite the amount of words
and turn it into a list.
i know how to do it (at least i think so) but my program keeps shutting down, i'm guessing because the file is pretty large.
any suggestions?Leave a comment:
-
Thanks for the advice.
I'm trying to create a spell checker which can spell check either a single word or a file depending on what the user chooses. The spell checker is really simple though, it doesn't point out a word that is spelled wrong, however it checks two different files to see if the word(s) is/are typed in are contained in either file. One of the files is a dictionary file with a list of words, and the other file is the user dictionary,...Leave a comment:
-
searching within a file
Does anyone know where I can read up on how to search for a particular object in a file? For example, search for a particular word in a dictionary? -
Thank you to everyone for their helpful suggestions.
I am yet again having a problem with one of the functions.
[code=python]def play(D):
points=0
option=raw_inpu t('Would you like to (H)it or (S)tay? ')
if 's' or 'S' in option:
print "Your hand has a value of " + str(handValue(u serHand))
print dealerHand
while handValue(deale rHand)<16:...Leave a comment:
-
A friend taking a computing course gave me the link to download a cards module, which was given through the course website. If you are interested in the module, the following is the link to access it.
http://www.cs.sfu.ca/CC/120/ggbaker/.../assign3-cards...Leave a comment:
-
thanks it does work
but i believe it also converts the ace into a 10
the ace needs to be a 1 or an 11 though...Leave a comment:
No activity results to display
Show More
Leave a comment: