Java and Numbers precission
Hi all.
I've found java does not treat numbers as I expected. For instance, if I write the code:
public class multi {
public static void main(String[] args) {
System.out.println(0.29*100.0);
}I'm very surprised to see that the console shows me the result: 28.999999999999996 (obviously it should be 29.0). The only way I've found to get the correct result, it has been casting the numbers by attaching 'f' at the end of each other (so casting them explicitly to floats).
Has anyone found the same problem, is there an easy way to solve it without doing the explicit cast?
Thanks all.
A few weeks? LOL.I meant @ these forums.I know. That's what made me giggle. It's been posted on the forum for at least the past three years or so...
Similar Messages
-
I'm new to Java and can't get javac command working
Ok first of all hello ( i'm new to the forum ), second i'm reading a book about Java and im trying to compile a sample code from the book, but javac command gained life and it's against me. So the book i'm reading is Sams Teach Yourself Java in 21 Days (YAY), and the code i want to compile is an application that works with another bit of code that mimics what a robot could do inside a volcano. So the Volcano program code is the following ( i'll post the robot code at the end of the post):
1: class VolcanoApp {
2: public static void main(String[] arguments) {
3: VolcanoRobot dante = new VolcanoRobot();
4: dante.status = ?exploring?;
5: dante.speed = 2;
6: dante.temperature = 510;
7:
8: dante.showAttributes();
9: System.out.println(?Increasing speed to 3.?);
10: dante.speed = 3;
11: dante.showAttributes();
12: System.out.println(?Changing temperature to 670.?);
13: dante.temperature = 670;
14: dante.showAttributes();
15: System.out.println(?Checking the temperature.?);
16: dante.checkTemperature();
17: dante.showAttributes();
18: }
19: }
Ignore the numbers they are used for explaining stuff in the book, and i din't copy the indentation.
So what i do is that i creat a file with notepad ( no fancy stuff only plain old notepad ) and i copy this code, remove the numbers and make the indents.
After that i save as .txt file with the apropriate name ( i know it's case sensitive ). After that i open command prompt and write:
javac VolcanoApp.java
And it tells me that "javac is not recognized as an internal or external command operable program or batch file".
I managed to solve that by going to the control panel and by adding to the system variables for my user in the path variable this :
;C:\JAVAJDK\bin
( C:\JAVAJDK is where JDK is installed)
And then i modified the system variables like this:
In the CLASSPATH i entered this .;%JAVA_HOME%\lib\tools.jar
In JAVA_HOME i entered this C:\JAVAJDK
Setting the variables like this made the javac error go away but now when i write in command line
javac VolcanoApp.java
It gives me this error
javac: file not found : VolcanoApp.java
Usage: javac options source files
use -help for a list of possible options
And then i read that i can drop my java file directly in the javac file. So i did.
When i drop my VolcanoApp.java in the javac file it open a command line window and writes a bunch of stuff in like a milisecond and shuts down. And no file is created.
I wanted to know what was writen in that window so i did it again and took a print screen and pasted it on paint ( it writed so much text that i only got a little bit but enough to see what hapend)
I read it and in the print screen it said it had 15 errors ( so far ) and then it point the errors with little arrows and there were characters that weren't present in the original code.
What hapend the compiler added wierd letters?
SO, my real question is, how the heck do i get javac working and compiling stuff properly?
Plz help i'm getting mad at this! ; (
And the code for the "robot":
1: class VolcanoRobot {
2: String status;
3: int speed;
4: float temperature;
5:
6: void checkTemperature() {
7: if (temperature > 660) {
8: status = ?returning home?;
9: speed = 5;
10: }
11: }
12:
13: void showAttributes() {
14: System.out.println(?Status: ? + status);
15: System.out.println(?Speed: ? + speed);
16: System.out.println(?Temperature: ? + temperature);
17: }
18: }
Again no indents and ignore the numbers. In the book it only said to compile the VolcanoApp.java , and not the VolcanoRobot.java
Edit:
I'm using Windows Vista Home Premium 32 bit.
Edited by: BBlop on Dec 13, 2009 11:29 AMguess what it says java file. So yes i'm sure. Sarcasm. Not the best way to encourage a total stranger to help you. Then there's
Sorry if i wasn't more clear but was that response needed?No it wasn't needed, but I'm not the one asking for help so I have the luxury of not worrying too much about it. It's extremely frustrating trying to drag relevant information out of someone, and makes one less inclined to bother.
Anyways, there's still nothing in this thread that actually explicitly says "there is a file called VolcanoApp.java in the directory where I'm running javac from" and I really can't be bothered banging my head against the wall any longer. You've made a silly mistake, or a false assumption. We all do it from time to time. My advice is, take a break, go for a walk and re-visit this in a while. You'll probably spot the mistake right away. -
Ive recently updated my mac to OS X 10.10 and now my CS5 illustrator and photoshop will not open... I uploaded the most recent Java and they still won't open. Please help
Mac,
Nothing shows up here?
https://www.adobe.com/account/my-products-services.html#
With CS5 you must have registered, hopefully under your present Adobe ID.
I am afraid the chat and phone support are off until the beginning of January.
Serial number and activation support (non-CC, chat open between 5AM and 7PM PST/PDT on workdays)
http://helpx.adobe.com/x-productkb/global/service1.html
Adobe ID and registration support (non-CC, chat open between 5AM and 7PM PST/PDT on workdays)
http://helpx.adobe.com/x-productkb/global/service-c1.html
http://helpx.adobe.com/adobe-connect/adobe-connect-phone-numbers.html -
I'm new to java and need help please
I have an assignment involves modifying a previous assignment. the code for the previous assigment is shown below.(it was required to be done as an applet this assigment can be an application or an applet) I'm trying to modify this code to read a text file (items.txt) that looks like this:
item # description price(this line does not appear in the text file)
001 shaving cream 400.00
999 razors 30.00
I need to load the item# and price from the text file into arrays(I have no clue how to use multi-dimensional arrays in java and would prefer not to)
I need to search the arrays based on the values entered by the user (item # and quantity) calculate the total for that item then create a new text file which has each line item for that order in the form:
item# quant price per item total(price per item*quant entered)
also also I need to be able to display the four items listed above after each loop as well as all the previous item number and quantities they selected until they indicate they don't want to select anymore.
I've been working on this for days and it seems like nothing I try works. My major problems are:
1. I have no idea how to read the text file and load those 2 items into their respective arrays
2. I can't seem to create a textfile that looks like text for the output file.
code]
import java.io.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.text.*;
import java.util.Locale;
public class arraySelection
extends JApplet {
//Initialize the applet
private Container getContentPane=null;
public void init() {
String string_item, string_quantity;
String output = "";
String description= "";
int counter= 0;
int itemNumber= 0;
double quantity = 0 ;
double tax_rate=.07;
double total= 0, price= 0;
double tax, subtotal;
double Pretotal= 0;
double priceArray[] = {1, .5, 3.65, 0.02, 0.09};
String descriptionArray[] = {"salt", "pepper", "paprika", "garlic", "thyme"};
// create number format for currency in US dollar format
NumberFormat moneyFormat = NumberFormat.getCurrencyInstance( Locale.US );
//format to have the total with two digits precision
DecimalFormat twoDigits = new DecimalFormat("0.00");
//Jtextarea to display results
JTextArea outputArea = new JTextArea ();
// get applet's content pane
Container container = getContentPane ();
//attach output area to container
container.add(outputArea);
//set the first row of text for the output area
output += "Invoice\nItem#\tDescription\tQuant@Price\t Line Total" + "\n";
do //begin loop structure obtain input from user
// obtain item number from user
string_item = JOptionPane.showInputDialog(
"Please enter an item number 1, 2, 3, 4, or 5:");
//obtain quantity of each item that user enter
string_quantity = JOptionPane.showInputDialog("Enter the quantity:");
// convert numbers from type String to Integer or Double
itemNumber = Integer.parseInt(string_item);
quantity = Double.parseDouble(string_quantity);
switch (itemNumber) {//Determine input from user to assign price and description
case 10: // user input item =10
price = priceArray[0];
description = descriptionArray[0];
break;
case 20: // user input item =20
price = priceArray [1];
description = descriptionArray[1];
break;
case 30: //user input item =30
price=priceArray[2];
description = descriptionArray[2];
break;
case 40: //user input item =40
price=priceArray[3];
description = descriptionArray[3];
break;
case 50: //user input item =50
price=priceArray[4];
description = descriptionArray[4];
break;
default: // user input item is not on the list
output += "Invalid value entered"+ "\n";
price=0;
description= "";
//Calculates the total for each item number and stores it in subtotal
subtotal = price * quantity;
//display input from user
output += itemNumber + "\t" + description + "\t\t"+ quantity + "@" +
moneyFormat.format( price) + "\t" + moneyFormat.format( subtotal) + "\n";
//accumulates the overall subtotal for all items
Pretotal = Pretotal + subtotal;
//verifies that the user wants to stop entering data
string_item = JOptionPane.showInputDialog(" Enter a positive integer to continue or 0 to stop. ");
itemNumber = Integer.parseInt(string_item);
// loop termination condition if user's input is 0 .It will end the loop
} while ( itemNumber!= 0);
tax = Pretotal * tax_rate; // calculate tax amount
total = Pretotal + tax; //calculate total = subtotal + tax
//appends data regarding the subtotal, tax, and total to the output area
output += "\n" + "Order Subtotal" + "\t" + moneyFormat.format( Pretotal) +
"\n" + "Tax" + "\t\t" + twoDigits.format( tax ) + "\n" + "Order Total" +
"\t\t" + moneyFormat.format( total );
//attaches the data in the output variable to the output area
outputArea.setText( output );
} //end init
}// end applet Invoice
Any help or sugestions would be greatly appreaciated. I've been working on this for over a week and everything I try goes nowhere.item # description price(this
line does not appear in the text file)
001 shaving cream 400.00
999 razors 30.00
I need to load the item# and price from the text file
into arrays(I have no clue how to use
multi-dimensional arrays in java and would prefer not
to)That's good, because you shouldn't use multidimensional arrays here. You should have a one-dimensional array (or java.util.List) of objects that encapsulate each line.
I've been working on this for days and it seems like
nothing I try works. My major problems are:
1. I have no idea how to read the text file and load
those 2 items into their respective arrays
2. I can't seem to create a textfile that looks like
text for the output file.The java.io package has file reading/writing classes.
Here's a tutorial:
http://java.sun.com/docs/books/tutorial/essential/io/index.html -
I'm new to java and need help please(repost)
I have an assignment involves modifying a previous assignment. the code for the previous assigment is shown below.(it was required to be done as an applet this assigment can be an application or an applet) I'm trying to modify this code to read a text file (items.txt) that looks like this:
item # description price(this line does not appear in the text file)
001 shaving cream 400.00
999 razors 30.00
I need to load the item# and price from the text file into arrays(I have no clue how to use multi-dimensional arrays in java and would prefer not to)
I need to search the arrays based on the values entered by the user (item # and quantity) calculate the total for that item then create a new text file which has each line item for that order in the form:
item# quant price per item total(price per item*quant entered)
also also I need to be able to display the four items listed above after each loop as well as all the previous item number and quantities they selected until they indicate they don't want to select anymore.
I've been working on this for days and it seems like nothing I try works. My major problems are:
1. I have no idea how to read the text file and load those 2 items into their respective arrays
2. I can't seem to create a textfile that looks like text for the output file.
import java.io.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.text.*;
import java.util.Locale;
public class arraySelection
extends JApplet {
//Initialize the applet
private Container getContentPane=null;
public void init() {
String string_item, string_quantity;
String output = "";
String description= "";
int counter= 0;
int itemNumber= 0;
double quantity = 0 ;
double tax_rate=.07;
double total= 0, price= 0;
double tax, subtotal;
double Pretotal= 0;
double priceArray[] = {1, .5, 3.65, 0.02, 0.09};
String descriptionArray[] = {"salt", "pepper", "paprika", "garlic", "thyme"};
// create number format for currency in US dollar format
NumberFormat moneyFormat = NumberFormat.getCurrencyInstance( Locale.US );
//format to have the total with two digits precision
DecimalFormat twoDigits = new DecimalFormat("0.00");
//Jtextarea to display results
JTextArea outputArea = new JTextArea ();
// get applet's content pane
Container container = getContentPane ();
//attach output area to container
container.add(outputArea);
//set the first row of text for the output area
output += "Invoice\nItem#\tDescription\tQuant@Price\t Line Total" + "\n";
do //begin loop structure obtain input from user
// obtain item number from user
string_item = JOptionPane.showInputDialog(
"Please enter an item number 1, 2, 3, 4, or 5:");
//obtain quantity of each item that user enter
string_quantity = JOptionPane.showInputDialog("Enter the quantity:");
// convert numbers from type String to Integer or Double
itemNumber = Integer.parseInt(string_item);
quantity = Double.parseDouble(string_quantity);
switch (itemNumber) {//Determine input from user to assign price and description
case 10: // user input item =10
price = priceArray[0];
description = descriptionArray[0];
break;
case 20: // user input item =20
price = priceArray [1];
description = descriptionArray[1];
break;
case 30: //user input item =30
price=priceArray[2];
description = descriptionArray[2];
break;
case 40: //user input item =40
price=priceArray[3];
description = descriptionArray[3];
break;
case 50: //user input item =50
price=priceArray[4];
description = descriptionArray[4];
break;
default: // user input item is not on the list
output += "Invalid value entered"+ "\n";
price=0;
description= "";
//Calculates the total for each item number and stores it in subtotal
subtotal = price * quantity;
//display input from user
output += itemNumber + "\t" + description + "\t\t"+ quantity + "@" +
moneyFormat.format( price) + "\t" + moneyFormat.format( subtotal) + "\n";
//accumulates the overall subtotal for all items
Pretotal = Pretotal + subtotal;
//verifies that the user wants to stop entering data
string_item = JOptionPane.showInputDialog(" Enter a positive integer to continue or 0 to stop. ");
itemNumber = Integer.parseInt(string_item);
// loop termination condition if user's input is 0 .It will end the loop
} while ( itemNumber!= 0);
tax = Pretotal * tax_rate; // calculate tax amount
total = Pretotal + tax; //calculate total = subtotal + tax
//appends data regarding the subtotal, tax, and total to the output area
output += "\n" + "Order Subtotal" + "\t" + moneyFormat.format( Pretotal) +
"\n" + "Tax" + "\t\t" + twoDigits.format( tax ) + "\n" + "Order Total" +
"\t\t" + moneyFormat.format( total );
//attaches the data in the output variable to the output area
outputArea.setText( output );
} //end init
}// end applet InvoiceAny help or sugestions would be greatly appreaciated. I've been working on this for over a week and everything I try goes nowhere.First answer: You shouldn't ask multiple questions in the same thread. Ask a specific question, with an appropriate subject line (optionally, assign the number of Dukes you are willing to give for the help). When question #1 is answered and question #2 arises, it's time for a new thread (don't forget to give out Dukes before moving on).
Second answer: I think you need a Transfer Object (http://java.sun.com/blueprints/patterns/TransferObject.html). It's whole purpose is to hold/transfer instance data where it is needed. Create a class something like this:
public class ItemTO
private String _number;
private String _description;
private double _price;
public ItemTO( String number, String description, double price )
_number = number;
_description = description;
_price = price
// Getter/Setter methods go here
}then, in the code where you read in the file do something like this:
BufferedReader input = null;
try
input = new BufferedReader( new FileReader( "c:\\a.txt" ) );
List items = new ArrayList();
String line;
String itemNumber;
String itemDescription;
double itemPrice;
while ( (line = input.readLine() ) != null )
System.out.println( line );
itemNumber = // Parse it from line
itemDescription // Parse it from line
itemPrice = // Parse it from line
items.add( new ItemTO( itemNumber, itemDescription, itemPrice ) );
catch ( FileNotFoundException fnfe )
fnfe.printStackTrace();
catch ( IOException ioe )
ioe.printStackTrace();
finally
try
if ( input != null )
input.close();
catch ( Exception e )
e.printStackTrace();
}As for how to parse the line of the file, I'll leave that to you for now. Are the three values delimited with any special characters?
jbisotti -
What is the use vss in java and how to use it?
can i know what is vss in java and how to use it and also can you tell me related vss like svs?
and what are tools for configuration in real we will use?
am i student i want to know these all?jduprez wrote:
You do not need to know them all, but one for sure, since it is a must for multi-developer team.8o( ?????
It is a must. Period.
OK, let's tone down: it is a must for any job related to software production. Not only development.That begsl the question, What does it mean to "know" one of these systems? I would expect Product Management, Documentation, QA, and Support staff to be conversant with the fundamentals of such a tool--check in, check out, version/revision numbers--but not much more than that. Developers, on the other hand, I would generally expect "know" the system with a much higher level of expertise--query language, branching, merging, and so on. -
Error using java and javascript
I have a jsp page that links to a bean and is working fine (getting data from the database).
On a html form I have a button with a picture that fires off javascript when clicked:
<BUTTON TYPE=reset onclick=showinfo('<%=index%>')>
<IMG SRC="http://localhost:8080/Portal/Images/q2.bmp" ALT="Info">
</BUTTON>
The javascript function just opens a new window and displays the text sent in:
<Script Language=JavaScript>
function showinfo(arrayindex)
InfoWin=window.open("","InfoWin","width=345,height=220");
InfoWin.document.write(arrayindex);
return false;
</Script>
Well in the above example index is a number (pulled from the database using a java bean and javascript converts it into a string then the function displays it correctly. If I replace <%=index%> with regular text it works fine as well(because java isn't used to pull data)! The problem occurs when I retrieve text data from the database and send it to the function. The web page gives errors about a nonterminating string. But I can move the code to somewhere else on the form(as long as I don't send it to java script) and it will print the text to the screen. I can also view the source of the web page and the html shows the text from the data base as if I hard coded the text into the javascript!!!!!!!!!!!!!!!!!
This must be a bug between java and javascript!
-can pass numbers(from a database) between the two
-can't pass text (from a database)between the two
Any info would help!Found the problem myself!
I am using an odbc connection to msaccess and the spaces in the text was messing things up!
After taking out the spaces it worked again. -
Oracle jdbc driver: sort order between letters and numbers
Hello,
I am facing a very strange problem with sortering of data between letters and numbers.
I'am executing the following SQL request:
SELECT nummsg FROM CWD01 where nummsg = '00000001' or nummsg = 'AAAA0001' order by nummsg
When this request is executed with sqlplus or SQuirreL, I receive the expected result:
NUMMSG
00000001
AAAA0001
When I execute the following java code:
try { String className = "oracle.jdbc.driver.OracleDriver"; Class driverObject = Class.forName(className); Connection con = DriverManager.getConnection("myurl", "user", "pass"); Statement stmt = con.createStatement(); ResultSet rs = stmt.executeQuery( "SELECT nummsg FROM CWD01 where nummsg = '00000001' or nummsg = 'AAAA0001' order by nummsg"); while (rs.next()) { String x = rs.getString("nummsg"); System.out.println("nummsg " +x); } } catch (Exception e) { System.out.println("Failed: Driver Error: "+ e.getMessage()); }
I receive the unexpected result:
nummsg AAAA0001
nummsg 00000001
We are using the following version of Oracle:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bi
and the following jdbc driver:
Oracle Database 10g Release 2 (10.2.0.1.0) JDBC Drivers (ojdbc14.jar (1,536,979 bytes) - classes for use with JDK 1.4 and 1.5)
Any suggestion?I checked, I'am sure of the problem:
package test;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
public class Test {
public static void main(String[] args) {
try {
String className = "oracle.jdbc.driver.OracleDriver";
Class driverObject = Class.forName(className);
Connection con = DriverManager.getConnection("jdbc:oracle:thin:@<server>[:<1521>]:<database_name>", "user", "password");
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery(
"SELECT nummsg FROM CWD01 where nummsg = '00000001' or nummsg = 'AAAA0001' order by nummsg");
while (rs.next()) {
String x = rs.getString("nummsg");
System.out.println("nummsg " + x);
} catch (Exception e) {
System.out.println("Failed: Driver Error: " + e.getMessage());
}The table CWD01 defines the column NUMMSG as VARCHAR2(8).
The output gives:
nummsg AAAA0001
nummsg 00000001 -
Letters and numbers like on lcd-screen
hi there,
i want to do a frame, where you can see something like a lcd-display with such letters and numbers (like on many counters). how can i do this ? are there any (standard)fonts i can use, or do i have to use images therefore ?
thanks in advance,
tobiasYou're probably gonna have to find a truetype font similar to what you want and then you can:
InputStream is = Thread.currentThread().getContextClassLoader().
getResourceAsStream( "com/youpackage/yourfont.TTF" );
Font f = Font.createFont( Font.TRUETYPE_FONT, is );
is.close();
Font lcdFont = f.deriveFont( 26f ); //sets the size you wantWhere com/youpackage/yourfont.TTF points to the font in your class path. Probably just stick the font in your jar file and it will find it there.
This will install the font on the users system to use in Java.
Mike -
Need Help w/ Java and Mozilla on SuSE 8.2
I am completely and totally new to Linux. Until not very long ago the only computer I ever worked with was MS. I'm running SuSE 8.2 Professional.
I used (after much trial and error) the rpm program to remove Mozilla 1.2 (which is installed by default). This is a machine at home so I have root access and regular access. I downloaded Mozilla 1.3 and installed that without a problem. I download j2sdk 1.4.1.02 (I'm pretty sure those are the numbers). I followed the instruction on how to install java and it appears to have worked correctly. I don't know how to test but there is now a directory called j2sdk1.4.1_02 which has several files and directories inside of it (including jre). I also followed the instructions and installed the java web start program.
Anyway, I've searched the forum for information that would explain how to make mozilla work on website that use java. Most of what I read was greek to me. But there was one that said I should copy the libjavaplugin_osi.so file into the mozilla plugins directory. I did that and when I looked at the "about plugins" page (from Help in Mozilla), it showed a lot of java files. But when I go to any pages that are using java, the page starts to load and then closes. This happened on about 6 different pages (all different web sites). So I think something went wrong. A friend had told me I'm going to have to make a "symlink" (which I don't know how to do). But he's on vacation and won't be back for 2 weeks.
Can anyone help?
Here are the directories where everything is stored. Oh, by the way, when I installed mozilla, java and javaws, I did all of it from the root account. If that was wrong, tell me and I'll fix it.
mozilla is in:
/usr/local/mozilla/
java is in:
/usr/local/java/j2sdk1.4.1_02/
javaws is in:
/usr/local/java/javaws/
Again, as I'm sure you can tell, I'm lost, totally new to linux, mozilla and java. So if you can help, please explain as clearly as possible.
Thanks in advance.Your friend is correct, instead of copying the .so file you should have made a symbolic link. To do that, first remove "libjavaplugin_oji.so" from "/usr/local/mozilla/plugins"; it's on the way. Then create the symlink with the "ln -s <source> <destination>" command, with your configuration it should be something like:
ln -s /usr/local/java/j2sdk1.4.1_02/jre/plugin/i386/ns610/libjavaplugin_oji.so
/usr/local/mozilla/plugins/
(you need to be root to do that)
To set up web start in mozilla, it might be easiest to go to the demo page and try to launch one of the applications:
http://java.sun.com/products/javawebstart/demos-nojavascript.html
When the "what should mozilla do with this file" dialog pops up, click on the "Advanced" button and make Mozilla handle it with the javaws application. Optionally remove the cross in "Always ask before opening .." -
Help creating an applet (prime numbers and numbers divisible by 4)
Hi all,
I am very new to java, and I have exhausted all of my resources before posting here. I have checked the archives but what I am looking for is not really there. I have an exam in 2 days, and there is a question like this one I cannot get to work.
I am supposed to ask for two numbers, the startNumber and endNumber. Then I am supposed to print in ascending or ascending order (this is already done)only the numbers divisible by 4 and the prime numbers. I have seen in the archives how you can use a boolean to check for prime numbers, but given the complexity of this question, I cannot put it into practice. Anybody can help me please?
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
public class Div4OrPrime extends Applet implements ActionListener
//DECLARE THE GUIS
public Button showB;
public Label startL, endL;
public TextField startN, endN;
private TextArea screen;
//DECLARE THE PANELS
public Panel topPanel, middlePanel, bottomPanel;
//DECLARING THE VARIABLES
public int startNumber, endNumber;
public int result;
public String output="";
public int counter;
//INITIALIZATION OF THE APPLET
public void init()
//CREATION OF THE BUTTONS
showB = new Button ("Show numbers");
//CREATION OF LABELS
startL = new Label ("Starting Number");
endL = new Label ("Ending Number");
//CREATION OF THE TEXTAREAS
startN = new TextField(8);
endN = new TextField(8);
screen=new TextArea();
//CREATION OF THE PANELS
topPanel=new Panel (new GridLayout (1,1));
middlePanel = new Panel (new GridLayout (1,4));
bottomPanel = new Panel (new GridLayout (1,1));
setLayout (new GridLayout (3,3));
//ADDING THE WIDGETS TO THE PANELS
topPanel.add(showB);
middlePanel.add(startL); middlePanel.add(startN);
middlePanel.add(endL); middlePanel.add(endN);
bottomPanel.add(screen);
add(topPanel);
add(middlePanel);
add(bottomPanel);
//ADD THE ACTION SOURCE LISTENER
showB.addActionListener(this);
startN.addActionListener(this);
endN.addActionListener(this);
//SET THE ACTION
public void actionPerformed(ActionEvent e)
output="";
if (e.getActionCommand().equals("Show numbers"))
startNumber=Integer.parseInt(startN.getText());
endNumber=Integer.parseInt(endN.getText());
if (startNumber<endNumber)
for (a = startNumber ; a<=endNumber; a++)
output= output +a+"\n";
screen.setText(output);
else if (startNumber>endNumber)
for (a=startNumber; a>=endNumber; a--)
output= output +a+"\n";
screen.setText(output);
repaint();
}Hi all,
Iam very new to java, and I have exhausted all of my
resources before posting here. I have checked the
archives but what I am looking for is not really
there. I have an exam in 2 days, and there is a
question like this one I cannot get to work.
I am supposed to ask for two numbers, the startNumber
and endNumber. Then I am supposed to print in
ascending or ascending order (this is already
done)only the numbers divisible by 4 and the prime
numbers. I have seen in the archives how you can use a
boolean to check for prime numbers, but given the
complexity of this question, I cannot put it into
practice. Anybody can help me please?
Code SNIP
I'm sure there are better ways than this but it's the only one I can think of offhand.
Create a boolean array from 2 to the largest number, set them all to true, then go through and on the first true number set all the multiples to false. Then do the same with the next true number(Sieve of Erasthoenes). Then you can go through and set all the mutiples of 4 to true with another loop. Then print the numbers in the range. -
ABAP , JAVA And XSLT Mapping Doc's
Hi,
I am new to SAP XI Any body please send me the Doc's Related to ABAP, JAVA And XSLT Mappings. Thanks in Advance.
Regards
Kiran.BHi
Refer to
ABAP mapping:
How to Use ABAP Mapping in XI 3.0
JAVA mapping:
http://help.sap.com/saphelp_nw04/helpdata/en/bd/c91241c738f423e10000000a155106/frameset.htm (Java mapping)
XSLT mapping:
https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/01a57f0b-0501-0010-3ca9-d2ea3bb983c1
/people/prasadbabu.nemalikanti3/blog/2006/03/30/xpath-functions-in-xslt-mapping
/people/sreekanth.babu2/blog/2005/01/05/design-time-value-mappings-in-xslt
/people/anish.abraham2/blog/2005/12/22/file-to-multiple-idocs-xslt-mapping
XSLT Mapping with java enhancement
/people/pooja.pandey/blog/2005/06/27/xslt-mapping-with-java-enhancement-for-beginners
XSLT - /people/dirk.roeckmann/blog/2006/07/26/grouping-xml-with-xslt--from-muenchian-method-to-xslt-20
Regards,
Kumar.
Reward points if helpful!! -
BI Java and BI ABAP -RSPLAN issue
Hi All
We are working with BI system ,using BI 7.0 Java and BI ABAP as separate systems on same host.
Already run the template intaller for BI Java and ABAP integration.
But facing some issue ,when going ot BI ABAP and RSPLAN and clicking the Start Mideller
it is opening a browser as http://host:8000/sap/public/myssocntl?sap-client-XXX
Since this is not correct and it should open BI Java portal instead of ABAP stack page.
Instead this should open a Url like this http://host:5XX00/webdynpro/dispatcher/sap.com/biplanworkbench1/Modeler?
I check on BI ABAP system under SAP Reference IMG -> SAP Customizing Implementation Guide-> SAP NetWeaver _> Business Intelligence-> BI Integrated Planning -> Settings for Starting the Planning Modeler.
There the default Url is BEx Portal Server and the url is
http://host:5XX00/webdynpro/dispatcher/sap.com/biplanworkbench1/Modeler
Can anybody let me know why this is going to ABAP server instead it should go to Java.
Regards
Ajay
Edited by: Ajay Sandal on Mar 10, 2009 2:31 PMHi Ajay ..
Good news that ur issue is resolved ..
I have somewhat similar issue .. Hopu u can put some light ..
I have Bi 7.o with Add on java ,
In RSPLAN from ABAP system , modular page is not coming . if i click on start moduler button in RSPLAN ..portal page is coming up and i have to give logging details .
Please suggest .
Thanks -
Plug-in for bullets and numbered lists in Mail??
Does anyone know of any plug-ins for the Mail app to do bullets and numbered lists like Entourage??
The lack of this functionality really makes Mail kinda lame and unusable for me.
Thanks!Paul,
the fact that Mail does not support bullit lists is not an oversight but was done on purpose. It may look good on your computer when you compose the message, but you have little influence in the way recipients see that message. It can get very messy, I can assure you.
If you want a perfect layout, compose in a wordprocessor and save as PDF, send that as an attachment. -
Bullets and Numbering buttons/options?
Hi. Am in a bit of a bind, hope someone can help.
Using InDesign CS 3.0.1 on Windows. Packaged and installed by the company I work for, so I cannot update manually (if it turns out I need to....?)
My problem: Cannot find any options for Bullets and Numbering.
It has just occurred to me, as I type this, that "InDesign 3.0.1" might not equate to "InDesign CS3" ? This is potentially very confusing! Do I have a version of InDesign here that doesn't have Bullet/Numbering buttons in the Paragraph Control Toolbar?
If these buttons should exist, I'd like to know why I don't have them. I have tried restoring prefs etc. to defaults but they're still not appearing.
Interestingly a search in the Help doesn't yield any answers, so I'm thinking I may have a version which doesn't have this feature?!?
Could someone confirm/deny, and let me know what version I need if it's the case that I have a previous version.
EDIT: Seems I might share this problem?.... http://groups.google.com/group/adobe.indesign.windows/browse_thread/thread/b27d031aa08292 6f
If so, I guess I need to find out how I can get the plugins installed by the company???
Thanks in advance.
David.Peter - does this tell you much?
Recovered File - no
Recovered MiniSave - no
Converted - no
Open As Copy - yes
Open Missing Plug-ins - no
Save As - yes
Created - yes
Transfered - no
Converted from QuarkXPress - no
Converted from PageMaker - no
Book - sync - no
Book - repaginate - no
Opened from InDesign Interchange - yes
Most recent Save - yes
Created on Windows 5.1 in app version 3.0.1.838 (FS InDesign Roman) build 838 on 16 July 2007 at 16:49
Opened from InDesign Interchange on Windows 5.1 in app version 3.0.1.838 (FS InDesign Roman) build 838 on 16 July 2007 at 16:49
Save As on Windows 5.1 in app version 3.0.1.838 (FS InDesign Roman) build 838 on 16 July 2007 at 17:02
Open As Copy on Windows 5.1 in app version 3.0.1.838 (FS InDesign Roman) build 838 on 17 July 2007 at 10:09
Save As on Windows 5.1 in app version 3.0.1.838 (FS InDesign Roman) build 838 on 17 July 2007 at 10:15
Save As on Windows 5.1 in app version 3.0.1.838 (FS InDesign Roman) build 838 on 09 October 2007 at 15:29
Save As on Windows 5.1 in app version 3.0.1.838 (FS InDesign Roman) build 838 on 09 October 2007 at 16:11
Save As on Windows 5.1 in app version 3.0.1.838 (FS InDesign Roman) build 838 on 09 October 2007 at 16:22
Save As on Windows 5.1 in app version 3.0.1.838 (FS InDesign Roman) build 838 on 28 April 2008 at 09:50
Most recent Save on Windows 5.1 in app version 3.0.1.838 (FS InDesign Roman) build 838 on 29 April 2008 at 12:57
Maybe you are looking for
-
Sharepoint 2010 Workflow successful: Sharepoint 2013 Workflow UNsuccessful:
Observation 1 1. I created 2 workflows that write "completed" to the workflow history a. 1 workflow uses sp2010 workflow manager b. 1 workflow uses sp2013 workflow manager 2. sp2010 workflow works fine; it will start either manually or automatica
-
External Monitoring with Decklink
First of all: CS 6 really is an epic improvement! It feels almost like a fcp 8. Almost... (system: Mac OSx 10.7.3, prp CS 6.0.1, deckllnk studio pro, 9.5.2) There some bugs, I think, that make life not sunny all the way through. 1. External monitorin
-
Default Expense Type in Travel Expense
Dear All I have a requirement. I have created 4 Expense Types AIR HOTEL TAXI TRAIN. Now my requirement is everytime employee tries to create an Expense Report in correspondence to the Travel Request, the expense type HOTEL gets defaulted in the lower
-
Using Spring JDBC with JHeadstart
We have to migrate a Forms application using JHeadstart. But all of the business logic is present in a set of PL/SQL code which is required to be reused for the J2EE based forms. Therefore, the JHeadstart migrated application needs to use the PL/SQL
-
Hi, I have an iMac 27" Intel i5 running 10.6.6 and for some reason I have been getting some firewire devices not being recognised. But for some reason my Macbook Pro which also runs 10.6.6 finds with no problem at all connecting to them. For example