Basic Programming Problem
Hi Guys, I need some help.
I want to increase and then decrease a number continuously.
for example: 0,1,2,3,4.....179,180, 179, 178,...3,2,1,0,1,2,3....179,180, etc..
Any ideas??
Regards!
Sam
Solved!
Go to Solution.
kekin wrote:
Why to waste precious memory???
Compared to anything else, the memory use here is insignificant. Even megabytes of data are no problem. The array is folded, meaning it is calculated at compile time and internally replaced with a diagram constant. Indexing a fixed size array is very efficient, meaning the code in the loop is significantly more efficient than hadling all these case structures and comparisons with every iteration.
The average computer has GBytes of RAM. The data structures here are a million times smaller. Insignificant!
If memory is really an issue, you can make it 4x smaller by changing the representation to U8 inside the FOR loop.
Just for fun, here's another solution that does not use arrays, case structures, or comparisons.
LabVIEW Champion . Do more with less code and in less time .
Attachments:
RampUpDown_B.png 6 KB
RampUpDown82_B.vi 16 KB
Similar Messages
-
Many basic programs are missing in my macbook pro
I don't know why but many basic programs are missing in my macbook pro.
I have mountain lion version.
some of them: make, port and etc.
I have a lot of problems with installation of programs in the terminal.
Is there any way to solve it? to install the whole package of programs which are supposed to be built-in?
NimrodI have make, after downloading XCode and its commandline extensions (free from App store). Can't help you with the others.
-
Coldfusion server problem or programming problem?
Hello experts,
I have been experiencing problems when accessing this website using Mac (and Parallels/WinXP).
http://tinyurl.com/3yh3d8l
Because there is no problem when using Windows PC, the programmer suggested that it might be a CF server problem, but one of my IT said it's programming issue (basically he said the web programmer is wrong). I have very limited access to PC at work but I need the data from that website. I'd like to give input to the webprogrammer but I don't know what to say. Could you please give me some suggestions? Thank you.hi Adam,
Just tested in Mac, the site works in FireFox. But Safari won't load it at all. Progress bar keep spinning but screen doesn't change.
So is this something to do with the programming problem or Safari is being picky? I can use FireFox during presentation but I'd like the option to be able to use Safari (iPad?). -
Hi all,
I was looking for this java programming problem which had to do with a large building and there was some gallons of water involved in it too somehow and we had to figure out the height of the buiding using java. This problem is also in one of the java books and I really need to find out all details about this problem and the solution. NEED HELP!!
Thanks
macYes, it will. The water will drain from the bottom of
the tank until the pressure from the water inside the
tank equals the pressure from the pipe. In other
words, without a pump, the water will drain out until
there is the same amount of water in the tank as in
the pipe The water pressure depends on the depth of the water, not the volume. So once the depth of the water inside the pipe reaches the same depth as the water inside the tank it will stop flowing. This will never be above the height of the tank.
I found this applet which demonstrates our problem. If you run it you can drag the guy up to the top, when water in his hose reaches the level of the water in the tank it will stop flowing out. -
Subject:
programming problem
Date:
Sun, 10 Mar 2002 19:48:34 +0800
From:
LibraryPublicStation <[email protected]>
Organization:
Hong Kong University of Science and Technology
Newsgroups:
hkust.cs.class.201
Hi, I have some problems on the following code:
The code has no compiling error. but
Why I can't get the RGB value of my image since I can get the width and
height of the image.
import java.io.*;
import java.util.*;
import java.awt.*;
import java.awt.image.*;
import java.awt.Graphics.*;
import java.awt.event.*;
import javax.swing.*;
import java.lang.*;
import java.awt.color.*;
import com.sun.image.codec.jpeg.*;
import java.awt.geom.*;
public class Sun
public static void main(String args[])
double[][] database_graph=new double[0][900];
// put the image in a row with 900 column
Toolkit toolkit = Toolkit.getDefaultToolkit();
Image image1 = new ImageIcon("imges.jpg").getImage();//load the image to
image1
BufferedImage buffer;//Buffer the image to get the RGB value
buffer = new BufferedImage(image1.getWidth(null),image1.getHeight(null),
BufferedImage.TYPE_INT_ARGB);
ColorModel a=buffer.getColorModel();
System.out.println(a);
for(int j=0;j<buffer.getWidth();j++)
for(int k=0;k<buffer.getHeight();k++)
int rgb=buffer.getRGB(j,k);//get the red,green,blue value of the graph
int red = ((rgb&0xff0000)>>16);
int green = ((rgb&0xff00)>>8);
int blue = rgb&0xff;
database_graph[0][buffer.getHeight()*j+k] = (red + green + blue)/3;
System.out.println(database_graph[0][buffer.getHeight()*j+k]+" "+red+"
"+green+" "+blue);
} // change back to gray scaleTry this :
ImageIcon icon = new ImageIcon("imges.jpg");
Image image1 = icon.getImage();
BufferedImage buffer = new BufferedImage(icon.getIconWidth(),icon.getIconHeight(), BufferedImage.TYPE_INT_ARGB);
...But I think, in your problem, you want to get the image in a BuffererdImage ?
ImageIcon icon = new ImageIcon("imges.jpg");
BufferedImage buffer= (BufferedImage)icon.getImage();
...Denis -
Hi, i'm Architec and my basic programs are: Autodesk Architecture and 3D studio Max. Can i run it in the MacBook Pro 13.3-Inch (NEWEST VERSION) Thanks!!!
You can but make sure you upgrade your RAM to 16GB - you can't do that through Apple...
Autodesk is a memory intensive program and the same goes with 3D Studio Max.....
Another suggeston if you must use a 13 inch is to buy the base 13 inch Macbook Pro and upgrade the RAM to 16GB and install a SSD to make it perform fast.
Another option is to get a refurbished 15 Inch Macbook Pro and do the RAM upgrade yourself...Advantage going 15 Inch is because it has it's own discrete graphics adapter rather than the built in Intel video. -
EJB Client - basic programming principles
Hello,
I'm new to the EJB world, can someone please give me some giudelines on basic programming principles on how to write a simple EJB client ?
Thanx people!
SonWe have some very simple "hello, world" examples here :
https://glassfish.dev.java.net/javaee5/ejb/EJB30.html
There is also an EJB FAQ :
https://glassfish.dev.java.net/javaee5/ejb/EJB_FAQ.html
Another resource is the Java EE 5 Tutorial :
http://java.sun.com/javaee/5/docs/tutorial/doc/
--ken -
dear sirs, i work with forms 6i
i have programming problem and i want to solve it
the problem is
i have table contain the following fields
AREA_CODE NOT NULL NUMBER(8)
AREA_NAME NOT NULL VARCHAR2(30)
EAREA_NAME VARCHAR2(30)
UP_AREA_CODE NUMBER(8)
AREA_TYPE NUMBER(1)
AREA_LEVEL NUMBER(15)
transfer_fees number(15,3)
i want to get the value of transfer_fees, depend on the area code which i want, but if transfer_fees is null i should get the other transfer_fees of the up_area_code as the up level of area code, and if also null then get the value of transfer_fees of the up level of area code and so on.
please help me urgently
YasserHi yasser
it's not precise for me , It needs a lot of details but according to the existing information
Now we have 3 options
Option1 : Get the transfer_fees according to AREA_CODE -- i don't know how not clear for me
Option 2 : IF transfer_fees IS NULL then get it's value from up_area_code (then i am assuming that up_area_code has a value currently during the user input so all we have is to think that we can get it's value from a simple assign statement in WHEN-VALIDATE-ITEM trigger of transfer_fees item as ...
IF :transfer_fees IS NULL THEN
:transfer_fees :=:up_area_code;
END IF;and so on...
Hope this helps...
Regards,
Amatu Allah -
I paid for basic program to convert PDF to Word or Excel - how to operate??
I paid for the basic program to convert PDF's to Word or Excel Documents. When I pull up the PDF I want to export and click on export icon in the tool bar it takes me back to sign up for the service which I have already paid for and received email confirmation - help!!!
1. Make sure you signed up for "ExportPDF" or "PDF Pack", not something else.
2. Check you are signing in with the SAME Adobe ID used to subscribe.
3. If no good, go to Manage Account on Adobe's site and check your subscription is active. (If you just paid it can take up to 48 hours for some reason). -
I'm new to Ubuntu & Linuz OS. I've started to see a pop-up window that says: System Program Problem Detected- Do you want to report the problem. When I click yes, I'm asked to enter my password to access problem reports of system programs. Should I be asked for my password ???
I am fairly new to Ubuntu, but that does not sound unexpected. Ubuntu tends to have everyone use a limited account that needs to ask for a password before carrying out operations like installing software.
-
I need help on a basic program
Hey people I need bit of help writting a very basic program for a project due on wednesday of this week. I am new at this I wanted to see if I could get some help from you.
I need basically to write a program that when you insert the year of birth it displays the chinease symbol or charater corresponding to the chinease horoscope, for example if I was born in 1982, my ymbol will be the dog... each animal repeats each 12 years, and there are 12 animals,,, some friends told me to do it with a do while, but as I am trying, it does not work that well or I don't do it well, ejejeje
Please help me
Juan AntonioIf you show us what you've done you are more likely to get help.
I don't think you need loops, have you been taught about the modulus operator "%" ? -
Hi
Is there a way of calling another program from within a small basic program ?
I dont mean run within it and then continue where it left off.
I simply ideally I ideally want to create one program that only contains menu options and depending on the user choice, then to go off and run another program.
If this is not possible..maybe I am getting over cautious, but does any one know the program size limit, if I need to put all teh features in one program ?
Thanks in advance
DaveYou would need an extension that can start an external exe (may be any exe includng another pre-compiled Small Basic program, or even the SmallBasicComplier to compile source and then run it), such as LDProcess.Start in my extension. There are also
other extensions with this or similar commands. -
O Dear! Basic Java Programming problem!
import java.lang.*;
import java.util.*;
import java.io.*;
import java.net.*;
import java.util.Random;
public class QuizApp extends Object
public static void main(String[] argStrings) throws Exception
Random random = new Random();
int generateFirstFigure = random.nextInt(21);
int generateSecondFigure = random.nextInt(31);
int generateOperator = random.nextInt(3);
String operator = "/";
int correctAnswer = generateFirstFigure + generateSecondFigure;
if (generateOperator == 0)
operator = "+";
int correctAnswer = generateFirstFigure + generateSecondFigure;
if (generateOperator == 1)
operator = "-";
int correctAnswer = generateFirstFigure - generateSecondFigure;
if (generateOperator == 2)
operator = "/";
int correctAnswer = generateFirstFigure / generateSecondFigure;
//int correctAnswer = generateFirstFigure + operator + generateSecondFigure;
int incorrectAnswerOne = correctAnswer -2;
int incorrectAnswerTwo = correctAnswer + 1;
int incorrectAnswerThree = correctAnswer + 3;
String questionOne = "What is " + generateFirstFigure + operator + generateSecondFigure + "?";
System.out.println(questionOne);
System.out.println(incorrectAnswerThree);
System.out.println(incorrectAnswerOne);
System.out.println(correctAnswer);
System.out.println(incorrectAnswerTwo);
}Basically this code, creates 2 random characters and then allows you to either add, divide or subtract the two numbers... firstly this bit of the code doesnt work, secondly how can the user input a value (the answer) to the math's question?
Thanks for help,
Joelpractissum wrote:
dketcham, i printed out your hello world pumpkin. its a huge hit in the office!Sorry for propogating the off-topic remarks...but link to the hello world pumpkin?it was the friday coding challenge for last week:
http://forum.java.sun.com/thread.jspa?threadID=5230548&messageID=9941964#9941964
It's all about the pretty colors, and trying to squish a simple little program into a squarish-shape, so that another shape can be put within!
As you can see, I have no real programming skills, but I like pretty colors, so it's all good. -
Extremely Basic Program - 1 Problem
This was assigned to me in my introductory Java class:
Write a program that reads an unspecified number of integers, determines how many positive and negative values have been read, and computes the total and average of the input values, not counting zeros. Your program ends with the input 0. Display the average as a floating-point number.
Here is the program I have written:
import javax.swing.JOptionPane;
public class AverageHW{
public static void main(String[] args){
int total, i;
double a, total2, i2;
int num, neg, pos;
neg = 0;
pos = 0;
total = 0;
i = 0;
while(1>0)
String input;
input = JOptionPane.showInputDialog(null,
"Enter a number to be averaged.",
"Enter",
JOptionPane.QUESTION_MESSAGE);
num = Integer.parseInt(input);
total += num;
++i;
if (num<0)
neg++;
if (num>0)
pos++;
if (num==0)
break;
a = (double)total / (double)i;
System.out.println("The sum is " + total);
System.out.println("The average is obviously not " + a); // Just a joke.. like my skills in Java
System.out.println("There are " + neg + " negative inputs." );
System.out.println("There are " + pos + " positive inputs.");
System.out.println("There are " + (i - 1) + " combined inputs.");
System.out.println("This is quite frustrating.");
}Getting a correct average is the only thing I'm lacking.
I might be missing something in the chapters I've studied that is keeping me from attaining a floating point average. My teacher also explained this to me before, and I forgot it. Tried searching all over the net and trying different things but to no avail. I know the answer must be extremely simple, but this seems to be the only thing holding me back, as you can see.
Also, this isn't the only reason I posted this. I'd like to get feedback on potentially alternative and more efficient methods of coding this program. I know I have different options as far as using alternative loops and such, but just some insight would be helpful.
Thank you!
EDIT I know i have some random useless crap variables thrown in there, but those are the leftovers of me messing around with getting that average (tried making all the variables in the average equation double variables).
Edited by: g_0_0_d4 on Dec 17, 2009 12:46 AMAfter reading your post pbrock, I was able to realize my mistake. "i" does not actually read the total numbers correctly, which is why I put "There are " + (i-1) + " combined inputs." I realized this earlier, but it never really registered that it was the compilation error that was causing the average to calculate incorrectly.
New code:
import javax.swing.JOptionPane;
public class AverageHW{
public static void main(String[] args){
int total, i;
double a, total2, i2;
int num;
int neg, pos;
neg = 0;
pos = 0;
total = 0;
i = 0;
while(1>0)
String input;
input = JOptionPane.showInputDialog(null,
"Enter a number to be averaged.",
"Enter",
JOptionPane.QUESTION_MESSAGE);
num = Integer.parseInt(input);
total += num;
i++;
if (num<0)
neg++;
if (num>0)
pos++;
if (num==0)
break;
i = (i-1);
a = (double)total / (double)i;
System.out.println("The sum is " + total);
System.out.println("The average is " + a);
System.out.println("There are " + neg + " negative inputs." );
System.out.println("There are " + pos + " positive inputs.");
System.out.println("There are " + i + " combined inputs.");
System.out.println("SUCCESS!");
JOptionPane.showMessageDialog(null,
"You have averaged your numbers.",
"Exit",
JOptionPane.INFORMATION_MESSAGE);
}Just removed (i-1) from the System.out.println and set i = i-1, it feels so good to finally finish.
Mel, your help is greatly appreciated. I should have known to use a boolean expression to determine the positive and negative numbers, but it kind of slipped my mind while I was writing this. The program you wrote is a little too advanced for my understanding, but I copy it down and study it for the future.
Thanks everyone! -
If i buy a used Mac Mini that can only run 10.6.8, will I immediately run into issues related to apps that are no longer supported on an older OS? I don't want to experience the same thing that happened with PPCs and 10.8.5.
ThanksI run an older Flash version, mind you one that is hacked slightly. I only view perhaps 15 min. of Youtube per week so I don't have a huge sample but I haven't encountered any real issues with my older version. Sure, YouTube warns me about using an older version but it seems to work. What doesn't work is my computer speed. No, not so much that but if I view a video in my browser it does not play smoothly. It works fine if I download it to my computer and then view it with VLC or Niceplayer outside the browser. When viewing things on YouTube I let them play in the browser, then if it's somethign I really, really want to see in nice presentation I download it and play it outside the browser. This all works even on my pretty old G4.
Flash player 11.1 hack on PowerPC - https://discussions.apple.com/message/16990862 - this gets FP to tell web sites you are running a newer version than you really are. This gets around web sites that don't really need a new version but think they know best. If they really do require it then this hack doesn't work.
Maybe you are looking for
-
How do I create an iDVD slide show that does not compress the photos making them low-res? When I insert the iDVD I have made into a DVD player connected to an HDTV, the playback quality of the pictures are very low. Is there a way to correct this wh
-
Safari & Snow Leopard: Change to 32 Bit or Rosetta
For those who are having problems with Safari & Snow Leopard, you have Agile Software (Maker of Password, which I highly recommend....) to thank for the following: http://support.agilewebsolutions.com/showthread.php?t=16716 Note: If you do not get th
-
Negative quantities in PM work order.
Hello Experts, We are planning to allow negative quantities in PM work order. Is there are any negative side effects of that? Thanks, Raneetha,
-
How do you change the My Info data?
I have a couple of questions I hope someone can help me with. First, how do you change the data listed on MY INFO? Secondly, when I go to MY CONTACTS I do not get the + to add or the edit function. Can someone please help with these questions?
-
Hello there. I am using a blackberry curve 8520. It came with version 4 of the OS. I upgradede it yesterday, 15 feb to version 5. After the upgrade so far I am experiencing 2 technical problems. 1 is with the blackberry protect app. which when I lau