20 Posted Topics
[QUOTE]PROBLEM #1: You have already created an array named NUMBERS with 20cells. You are to initialize all of the cells with odd subscripts to 1 and all of the cells with even subscripts to 2. MY TAKE ON IT: I <-- 1 DOWHILE I<= 20 NUMBERS (I) <-- 1 I …
you flip the bits and add 1. its also known as twos complement. TJ
1 is not technically a prime number either so it is not true to print it out as prime with two and three.
Hey Everyone... Not quite sure how it works on these forums as this is my first post, but I am looking to separate elements of lines printed to a text file in real-time for a log parser. An example of the text output is: [INDENT][CHAT WINDOW TEXT] [Sun Nov 29 …
as in: [code] int total; for (int i = 0; i<100; i++) { if (i%2==1) total+=i; } [/code] ? I think that would server your intended function, but i would do it without modulus and change the for loop to look like: [code] for(int i = 1; i<100; i+2) { …
Is this possible to do? I am looking to parse some data out of a file and based on the results of this take names found in the file and create objects out of them. for example... [code] //you have parsed the name Bob out of a file and it …
Is it possible to read a file as lines are written to it but not lose your location in the file? As in there is a program that will write lines of text to a file until it reaches 2.4MB. I want to read this file as these lines of …
Hey guys, so i've posted here before about regex, and i was told that some of you may be able to check my regexes for errors after i have created them. I have one that looks like it should work to me, but it absolutely will not. [code] public static …
go to [url]www.javabat.com[/url] if you want some practice problems. its beyond useful, and even has solution code to some problems if you get stuck. TJ
the code for the error would be written as [code] for(count=0; count<num_of_scores; count++) { System.out.print("Enter the scores "); score[count]=input.nextInt(); if (score[count]<0 || score[count]>100) break; sum += score[count]; } [/code] in order to ignore the lowest score, i would use an ArrayList as such: [code] //ArrayList variable public ArrayList<Integer> score = …
it would be: [code] else if (Earn>=116 && Earn<=200) { //statement to execute here } [/code] hope this helps. TJ
for the part [code]//How do I step into this Loop? while ( repeat =='Y'|| repeat =='y');[/code] i believe that using [code] while ( repeat.equalsCaseInsensitive("Y")) { }[/code] will enable you to enter the loop... iirc, you need to use .equals() to compare two strings, not the == operator. TJ
well first off you need to initialize a scanner using [code]Scanner song = new Scanner(System.in);[/code] and then you need to call in the .nextline() method to grab all of the information the user inputs until they hit enter. TJ
Sorry, i'm a newer programmer so i am not sure what you mean by the & needs to be escaped, but if you take a look at my thread about regex you may find it helpful. [URL="http://www.daniweb.com/forums/thread242302.html"]Parsing Lines of a File[/URL] TJ
Try this: [URL="http://java.sun.com/j2se/1.4.2/docs/api/javax/sound/midi/package-summary.html"]http://java.sun.com/j2se/1.4.2/docs/api/javax/sound/midi/package-summary.html[/URL] TJ
Okay, so the formulas for temperature are: F = 1.8*C + 32 C = (F-32)/1.8 try incorporating these into your program using if/else statements checking for whether or not it is celcius. After you do this, come back with your new code and i can help you out more if …
[CODE]for(int i = 1; i <= rows; i++) { for(int j = 1; j <=columns; j++) r = r + " _"; r = r + "\n"; }[/CODE] Your nested "if" statement's statements are not defined correctly, and/or your indenting is problematic. I BELIEVE your code should look like this: …
Hey everyone- my name is TJ, and I am currently taking an AP Computer Science class in my high school. We are learning java, so most if not all of my quetions will be java related. Right now, I am undertaking a project for an online gaming community I participate …
why wouldnt you put the whole body of the main method inside a while (true) { } loop so that it infinitely loops until you hit submit with nothing selected or some such thing. I believe the technical term for what i am trying to say is make it a …
You would not want to use else if, because if a number is a multiple of say 2 and 5, it will only print "This" istead of printing "This Java". TJ
The End.
tjsail