|
Hi I was wondering if I could get some help with my java program, for my computer engineering class.
I need to write a program that does the following:
• Ask the user for a number in the decimal (base 10) number system
• Store this number into a variable with a suitable type and name
• Take this number and convert it into binary (base 2) using the algorithm learned in the previous unit. – take the number, divide it by two, keep track of the remainder, continue until you reach a quotient of 0.
• To find the remainder, you need to use the ‘mod’ function
• It is possible to add to a variable of type String – this is needed to keep track of your binary converted number
Since I didn't really understand the whole adding string variables concept, I decided to stick with what I do know.
- Based on that, I came up with this program, but the thing is, the conversion to binary comes out backwards.
- take the number 11 for example: instead of 1011, I get 1101 when it is converted into binary.
- basically I need help getting it to switch the numbers around
**This is the program that I came up with:
int input;
int r;
System.out.println ("Please input a number in the base 10 number system.");
input = Integer.parseInt (in.readLine());
while (input != 0)
{
r = input % 2
System.out.print(r);
input = input / 2;
}
if (input == 0)
{
System.out.print ("0");
}
Any help with this is much appreciated. Thanks ahead of time.
|
|
|
|
|
Well, a quick fix to your problem of reversed digits in binary ---- convert your int variable to a string and swap the individual binary bits around, then convert back to int if desired or just leave it as a string and print it that way.
John P.
|
|
|
|
|
Please let me know what is the use of appenders that is included in the properties file of log4j. And how it works?
THANKS.
|
|
|
|
|
i am planning to making soma cube.
i am looking for data about soma cube, and find this site.
" http://users.ids.net/~salberg/soma/Soma.html "
i try to control block by using SHIFT, CTORL key but i can't.
i want to know how am i control these block~
i will very thank you for giving me tip.
Have a good day~
firstly, i am sorry, i am from korea.
and i am not good in wriitting english so please understand~
Thank you everyone~
|
|
|
|
|
Suppose I have a multithreaded application which is using log4j and there are three threads t1,t2and t3 running and calling the same logging function passing a message aolng with threadID, for instance log.info("info message"). So how does log4j handles this. Please let me know how does log4j synchronizes these threads so that only one thread runs at a times. Were does this synchronization takes place.
THANKS.
|
|
|
|
|
Hey,
I have a java menu, presented through a SSI.
Problem is, the drop down menus are always hidden behind any Flash paper we use on the site.
Does anyone have any ideas how to get around this?
(i have already tried changing all the Z-Index's)
Regards,
Spike
|
|
|
|
|
<small><big>I know how to extract jar file but I just want to create a jar file<br />
help me </big></small>
|
|
|
|
|
what IDE do you use ?
eclipse ?
|
|
|
|
|
<big>how many paths are to be set in core, advance,j2ee,j2me in Java in the environment variable of the systems property<br />
explain me with variable name and variable value which i can set in systems property and software inforemation which can i use in java</big>
|
|
|
|
|
I'm sorry, but I don't understand anything of what you say.
please rephrase, and explain shortly what you want.
also, please don't format in big colored letters, it's harder to read.
|
|
|
|
|
Hi java Gurus my code is as shown below....
import java.net.*;
import java.io.*;
import java.util.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Vector;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
class ConnectionTest {
public static void main(String[] args) {
try
{
URL yahoo = new URL("http://www.overstock.com/Jewelry-Watches/Rings/2360/cat.html");
URLConnection yahooConnection = yahoo.openConnection();
DataInputStream dis = new DataInputStream(yahooConnection.getInputStream());
String inputLine;
//int tablecount=0;
int start=0;
while ((inputLine = dis.readLine()) != null) {
if(inputLine.contains("<table")) {
start++;
}
if(start!=0) {
System.out.println(inputLine);
}
if(inputLine.contains("</table>"))
{
start--;
}
}
dis.close();
}
catch (MalformedURLException me) {
System.out.println("MalformedURLException: " + me);
}
catch (IOException ioe)
{
System.out.println("IOException: " + ioe);
}
}
}
Now my code extracts all the <table>s from the web page I need to display only the product and price table data and block table data like advertisements ,copyright notes and navigation panels.
Java gurus plzzzz help me out in altering the code and getting the result.<pre></pre>
|
|
|
|
|
Replace your while block with following.. Hope thats what you are looking for..
while ((inputLine = dis.readLine()) != null) {
if (inputLine.contains("START PRODUCT BOX")) {
start++;
}
if (start != 0) {
System.out.println(inputLine);
}
if (inputLine.contains("END PRODUCT BOX")) {
start--;
}
}
Cheers,
Sudarshan
|
|
|
|
|
Hi all,
I got a server-client application, the server creates new thread when it accepts the incoming connection. I got some data on the server which I need to access. I thought about putting the data into the the thread itself, but if the thread1 updates those data and say thread2 access those data it would only have old copy of the data. So, I'm not too sure how to go about implementing it. If someone could shed some light this way I would be very much appreciated.
Thank you for your time reading this question
|
|
|
|
|
hi,
can someone please help me with writing a pseudocode algorithm for finding the SHORTEST PATH by using Dijkstra's algorithm?
cheers
|
|
|
|
|
that's a mighty tough question, 3rd year?
|
|
|
|
|
JNIEXPORT jstring JNICALL Java_playaudio_BeatTrack_myBeatTrack
(JNIEnv *env, jobject obj, jstring wavfile)
{
const char* filename = env->GetStringUTFChars(wavfile,0);
BeatTrack(filename);
env->ReleaseStringUTFChars(wavfile,filename);
return NULL;
}
for my BeatTrack method, I just need the filename, then it can run,
if I comment the BeatTrack(filename);, then no problem, for the java calling,
of course, my BeatTrack(const *char filename) has no problem, cause I have test it,,
but I call this method in java, the error is as follows,
Java VM: Java HotSpot(TM) Client VM (10.0-b19 mixed mode, sharing windows-x86)
# Problematic frame:
# C [beattrack.dll+0x130b]
#
# An error report file with more information is saved as:
# D:\programs\playAudio\hs_err_pid11684.log
#
# If you would like to submit a bug report, please visit:
# http://java.sun.com/webapps/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
any idea??
|
|
|
|
|
Please clarify and help to solve the following problem:
x1 and y1 are planned to run in same server.
X1 is set to run using default port as X1.central
y1 is set to run using port 90 as Y1.central:90/
Problem is if the user specify Y1.central/ without the port # obviously it go to X1 page.
Is there any possibility to redirect the page to Y1 if the user specify Y1.central (without port number) ?
Can we do some config settings in /etc/inet.d file to route
Y1.central to Y1.central:90
Basically client also prefers the URL to be without the port #.
Is there any config need to done in inetd.d. Application will run on solaris platform.
|
|
|
|
|
actually I'm researcher for build multi-agent system. This is my detail
project title : "MULTI-AGENT SYSTEM FOR PRODUCTION REAL TIME TRACKER"
Platform : Open Agent Architecture
Language : Interagent Communication Language (ICL) in Java programming
Methodology : Gaia Methodologies
so far...i'm still do not know, how to start the coding to develop my agent..so far i already done to run the oaa runtime following the tutorial but i'm still not understand and do not know how to implement for my programming using the netbeans...and how can i interact for my agent to current database
plz help me.....
~(^_^)~
|
|
|
|
|
this is not the right place to ask this.
if you're hiring, go to the job forum.
if you want others to write code for you, go to www.rentacoder.com[^]
otherwise, ask a specific and technical question...
|
|
|
|
|
hi
I am new to java sound, and want to play the sound while draw the waveform in realtime , any idea or open souce?
|
|
|
|
|
how can i refresh the jsp page to display the value of the variable set by the java in same process
|
|
|
|
|
|
hello dear,
I have one jsp with one button on click the button servlet will invoke & then java file in java i m calculating percentage and store it in variable that value i want to display on jsp
user can see the percent of processing
help me
|
|
|
|
|
Write a Rectangle class.
This class represents Rectangles. Each Rectange has the X and Y coordinates of its center point (as doubles) and its width and height (as double values, too). No other values should be stored! This means no area, no perimeter!
The class should have the following constructors and methods:
1. a constructor that takes X, Y, width, and height as arguments;
2. a constructor that takes only width and height as arguments;
3. a default constructor;
4. a method setCenter that takes X and Y as arguments;
5. a method setWidth that takes a width value;
6. a method setHeight that takes a height value;
7. a method getX that returns the X coordinate;
8. a method getY that returns the Y coordinate;
9. a method getWidth that returns the width value;
10. a method getHeight that returns the height value;
11. a method getArea calculates the area of the rectangle and returns it;
12. a method getPerimeter it calculates the perimeter of the rectangle and returns it;
13. a method toString that creates a String that includes the X, Y center coordinates, width, and height, and returns the string. This method does not use System.out.println() itself. It returns a String value to the caller.
Write an application (RectangleTest.java) to test your Rectangle class.
Your Application should test all the constructors and methods.
I need a submission of Both files: Rectangle.java and RectangleTest.java
please email me at T45russ@aol.com if you can write this program. I have been trying so hard and can't make it work. Thanks to all.
|
|
|
|
|