Search Results

Search found 521 results on 21 pages for 'calculator'.

Page 3/21 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • 'SImple' 2 class Java calculator doesn't accept inputs or do calculations

    - by Tony O'Keeffe
    Hi, I'm trying to get a two class java calculator working (new to java) to work but so far i'm having no success. the two classes are outlined below, calcFrame is for the interface and calEngine should do the actual calculations but i can't get them to talk to one another. i'd really appreciate any assistance on same. Thanks. CalcFrame Code - import java.awt.; import javax.swing.; import javax.swing.border.; import java.awt.event.; /** *A Class that operates as the framework for a calculator. *No calculations are performed in this section */ public class CalcFrame implements ActionListener { private CalcEngine calc; private JFrame frame; private JTextField display; private JLabel status; /** * Constructor for objects of class GridLayoutExample */ public CalcFrame() { makeFrame(); //calc = engine; } /** * This allows you to quit the calculator. */ // Alows the class to quit. private void quit() { System.exit(0); } // Calls the dialog frame with the information about the project. private void showAbout() { JOptionPane.showMessageDialog(frame, "Group Project", "About Calculator Group Project", JOptionPane.INFORMATION_MESSAGE); } private void makeFrame() { frame = new JFrame("Group Project Calculator"); makeMenuBar(frame); JPanel contentPane = (JPanel)frame.getContentPane(); contentPane.setLayout(new BorderLayout(8, 8)); contentPane.setBorder(new EmptyBorder( 10, 10, 10, 10)); /** * Insert a text field */ display = new JTextField(); contentPane.add(display, BorderLayout.NORTH); //Container contentPane = frame.getContentPane(); contentPane.setLayout(new GridLayout(4, 4)); JPanel buttonPanel = new JPanel(new GridLayout(4, 4)); contentPane.add(new JButton("1")); contentPane.add(new JButton("2")); contentPane.add(new JButton("3")); contentPane.add(new JButton("4")); contentPane.add(new JButton("5")); contentPane.add(new JButton("6")); contentPane.add(new JButton("7")); contentPane.add(new JButton("8")); contentPane.add(new JButton("9")); contentPane.add(new JButton("0")); contentPane.add(new JButton("+")); contentPane.add(new JButton("-")); contentPane.add(new JButton("/")); contentPane.add(new JButton("*")); contentPane.add(new JButton("=")); contentPane.add(new JButton("C")); contentPane.add(buttonPanel, BorderLayout.CENTER); //status = new JLabel(calc.getAuthor()); //contentPane.add(status, BorderLayout.SOUTH); frame.pack(); frame.setVisible(true); } /** * Create the main frame's menu bar. * The frame that the menu bar should be added to. */ private void makeMenuBar(JFrame frame) { final int SHORTCUT_MASK = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(); JMenuBar menubar = new JMenuBar(); frame.setJMenuBar(menubar); JMenu menu; JMenuItem item; // create the File menu menu = new JMenu("File"); menubar.add(menu); // create the Quit menu with a shortcut "Q" key. item = new JMenuItem("Quit"); item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Q, SHORTCUT_MASK)); item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { quit(); } }); menu.add(item); // Adds an about menu. menu = new JMenu("About"); menubar.add(menu); // Displays item = new JMenuItem("Calculator Project"); item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { showAbout(); } }); menu.add(item); } /** * An interface action has been performed. * Find out what it was and handle it. * @param event The event that has occured. */ public void actionPerformed(ActionEvent event) { String command = event.getActionCommand(); if(command.equals("0") || command.equals("1") || command.equals("2") || command.equals("3") || command.equals("4") || command.equals("5") || command.equals("6") || command.equals("7") || command.equals("8") || command.equals("9")) { int number = Integer.parseInt(command); calc.numberPressed(number); } else if(command.equals("+")) { calc.plus(); } else if(command.equals("-")) { calc.minus(); } else if(command.equals("=")) { calc.equals(); } else if(command.equals("C")) { calc.clear(); } else if(command.equals("?")) { } // else unknown command. redisplay(); } /** * Update the interface display to show the current value of the * calculator. */ private void redisplay() { display.setText("" + calc.getDisplayValue()); } /** * Toggle the info display in the calculator's status area between the * author and version information. */ } CalcEngine - public class CalcEngine { // The calculator's state is maintained in three fields: // buildingDisplayValue, haveLeftOperand, and lastOperator. // The current value (to be) shown in the display. private int displayValue; // The value of an existing left operand. private int leftOperand; /** * Create a CalcEngine. */ public CalcEngine() { clear(); } public int getDisplayValue() { return displayValue; } /** * A number button was pressed. * Either start a new operand, or incorporate this number as * the least significant digit of an existing one. * @param number The number pressed on the calculator. */ public void numberPressed(int number) { if(buildingDisplayValue) { // Incorporate this digit. displayValue = displayValue*10 + number; } else { // Start building a new number. displayValue = number; buildingDisplayValue = true; } } /** * The 'plus' button was pressed. */ public void plus() { applyOperator('+'); } /** * The 'minus' button was pressed. */ public void minus() { applyOperator('-'); } /** * The '=' button was pressed. */ public void equals() { // This should completes the building of a second operand, // so ensure that we really have a left operand, an operator // and a right operand. if(haveLeftOperand && lastOperator != '?' && buildingDisplayValue) { calculateResult(); lastOperator = '?'; buildingDisplayValue = false; } else { keySequenceError(); } } /** * The 'C' (clear) button was pressed. * Reset everything to a starting state. */ public void clear() { lastOperator = '?'; haveLeftOperand = false; buildingDisplayValue = false; displayValue = 0; } /** * @return The title of this calculation engine. */ public String getTitle() { return "Java Calculator"; } /** * @return The author of this engine. */ public String getAuthor() { return "David J. Barnes and Michael Kolling"; } /** * @return The version number of this engine. */ public String getVersion() { return "Version 1.0"; } /** * Combine leftOperand, lastOperator, and the * current display value. * The result becomes both the leftOperand and * the new display value. */ private void calculateResult() { switch(lastOperator) { case '+': displayValue = leftOperand + displayValue; haveLeftOperand = true; leftOperand = displayValue; break; case '-': displayValue = leftOperand - displayValue; haveLeftOperand = true; leftOperand = displayValue; break; default: keySequenceError(); break; } } /** * Apply an operator. * @param operator The operator to apply. */ private void applyOperator(char operator) { // If we are not in the process of building a new operand // then it is an error, unless we have just calculated a // result using '='. if(!buildingDisplayValue && !(haveLeftOperand && lastOperator == '?')) { keySequenceError(); return; } if(lastOperator != '?') { // First apply the previous operator. calculateResult(); } else { // The displayValue now becomes the left operand of this // new operator. haveLeftOperand = true; leftOperand = displayValue; } lastOperator = operator; buildingDisplayValue = false; } /** * Report an error in the sequence of keys that was pressed. */ private void keySequenceError() { System.out.println("A key sequence error has occurred."); // Reset everything. clear(); } }

    Read the article

  • Problem creating calculations 'engine' in two class java calculator

    - by tokee
    i have hit a brick wall whilst attempting to create a two class java calculator but have been unsuccessful so far in getting it working. i have the code for an interface which works and displays ok but creating a seperate class 'CalcEngine' to do the actual calculations has proven to be beyond me. I'd appreciate it if someone could kick start things for me and create a class calcEngine which works with the interface class and allows input when from single button i.e. if one is pressed on the calc then 1 displays onscreen. please note i'm not asking someone to do the whole thing for me as i want to learn and i'm confident i can do the rest including addition subtraction etc. once i get over the obstacle of getting the two classes to communicate. any and all assistance would be very much appreciated. Please see the calcInterface class code below - import java.awt.*; import javax.swing.*; import javax.swing.border.*; import java.awt.event.*; /** *A Class that operates as the framework for a calculator. *No calculations are performed in this section */ public class CalcFrame implements ActionListener { private CalcEngine calc; private JFrame frame; private JTextField display; private JLabel status; /** * Constructor for objects of class GridLayoutExample */ public CalcFrame() { makeFrame(); //calc = engine; } /** * This allows you to quit the calculator. */ // Alows the class to quit. private void quit() { System.exit(0); } // Calls the dialog frame with the information about the project. private void showAbout() { JOptionPane.showMessageDialog(frame, "Group Project", "About Calculator Group Project", JOptionPane.INFORMATION_MESSAGE); } private void makeFrame() { frame = new JFrame("Group Project Calculator"); makeMenuBar(frame); JPanel contentPane = (JPanel)frame.getContentPane(); contentPane.setLayout(new BorderLayout(8, 8)); contentPane.setBorder(new EmptyBorder( 10, 10, 10, 10)); /** * Insert a text field */ display = new JTextField(); contentPane.add(display, BorderLayout.NORTH); //Container contentPane = frame.getContentPane(); contentPane.setLayout(new GridLayout(4, 4)); JPanel buttonPanel = new JPanel(new GridLayout(4, 4)); contentPane.add(new JButton("1")); contentPane.add(new JButton("2")); contentPane.add(new JButton("3")); contentPane.add(new JButton("4")); contentPane.add(new JButton("5")); contentPane.add(new JButton("6")); contentPane.add(new JButton("7")); contentPane.add(new JButton("8")); contentPane.add(new JButton("9")); contentPane.add(new JButton("0")); contentPane.add(new JButton("+")); contentPane.add(new JButton("-")); contentPane.add(new JButton("/")); contentPane.add(new JButton("*")); contentPane.add(new JButton("=")); contentPane.add(new JButton("C")); contentPane.add(buttonPanel, BorderLayout.CENTER); //status = new JLabel(calc.getAuthor()); //contentPane.add(status, BorderLayout.SOUTH); frame.pack(); frame.setVisible(true); } /** * Create the main frame's menu bar. * The frame that the menu bar should be added to. */ private void makeMenuBar(JFrame frame) { final int SHORTCUT_MASK = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(); JMenuBar menubar = new JMenuBar(); frame.setJMenuBar(menubar); JMenu menu; JMenuItem item; // create the File menu menu = new JMenu("File"); menubar.add(menu); // create the Quit menu with a shortcut "Q" key. item = new JMenuItem("Quit"); item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Q, SHORTCUT_MASK)); item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { quit(); } }); menu.add(item); // Adds an about menu. menu = new JMenu("About"); menubar.add(menu); // Displays item = new JMenuItem("Calculator Project"); item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { showAbout(); } }); menu.add(item); } /** * An interface action has been performed. * Find out what it was and handle it. * @param event The event that has occured. */ public void actionPerformed(ActionEvent event) { String command = event.getActionCommand(); if(command.equals("0") || command.equals("1") || command.equals("2") || command.equals("3") || command.equals("4") || command.equals("5") || command.equals("6") || command.equals("7") || command.equals("8") || command.equals("9")) { int number = Integer.parseInt(command); calc.numberPressed(number); } else if(command.equals("+")) { calc.plus(); } else if(command.equals("-")) { calc.minus(); } else if(command.equals("=")) { calc.equals(); } else if(command.equals("C")) { calc.clear(); } else if(command.equals("?")) { } // else unknown command. redisplay(); } /** * Update the interface display to show the current value of the * calculator. */ private void redisplay() { display.setText("" + calc.getDisplayValue()); } /** * Toggle the info display in the calculator's status area between the * author and version information. */ }

    Read the article

  • actionlistener not responding in java calculator

    - by tokee
    hi, please see calculator interface code below, from my beginners point of view the "1" should display when it's pressed but evidently i'm doing something wrong. any suggestiosn please? import java.awt.*; import javax.swing.*; import javax.swing.border.*; import java.awt.event.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JPanel; /** *A Class that operates as the framework for a calculator. *No calculations are performed in this section */ public class CalcFrame extends JPanel { private CalcEngine calc; private JFrame frame; private JTextField display; private JLabel status; /** * Constructor for objects of class GridLayoutExample */ //public CalcFrame(CalcEngine engine) //{ //frame.setVisible(true); // calc = engine; // makeFrame(); //} public CalcFrame() { makeFrame(); calc = new CalcEngine(); } class ButtonListener implements ActionListener { ButtonListener() { } public void actionPerformed(ActionEvent e) { if (e.getActionCommand().equals("1")) { System.out.println("1"); } } } /** * This allows you to quit the calculator. */ // Alows the class to quit. private void quit() { System.exit(0); } // Calls the dialog frame with the information about the project. private void showAbout() { JOptionPane.showMessageDialog(frame, "Declan Hodge and Tony O'Keefe Group Project", "About Calculator Group Project", JOptionPane.INFORMATION_MESSAGE); } // ---- swing stuff to build the frame and all its components ---- /** * The following creates a layout of the calculator frame. */ private void makeFrame() { frame = new JFrame("Group Project Calculator"); makeMenuBar(frame); JPanel contentPane = (JPanel)frame.getContentPane(); contentPane.setLayout(new BorderLayout(8, 8)); contentPane.setBorder(new EmptyBorder( 10, 10, 10, 10)); /** * Insert a text field */ display = new JTextField(8); contentPane.add(display, BorderLayout.NORTH); //Container contentPane = frame.getContentPane(); contentPane.setLayout(new GridLayout(4, 5)); JPanel buttonPanel = new JPanel(new GridLayout(4, 4)); contentPane.add(new JButton("9")); contentPane.add(new JButton("8")); contentPane.add(new JButton("7")); contentPane.add(new JButton("6")); contentPane.add(new JButton("5")); contentPane.add(new JButton("4")); contentPane.add(new JButton("3")); contentPane.add(new JButton("2")); contentPane.add(new JButton("1")); contentPane.add(new JButton("0")); contentPane.add(new JButton("+")); contentPane.add(new JButton("-")); contentPane.add(new JButton("/")); contentPane.add(new JButton("*")); contentPane.add(new JButton("=")); contentPane.add(new JButton("C")); contentPane.add(new JButton("CE")); contentPane.add(new JButton("%")); contentPane.add(new JButton("#")); //contentPane.add(buttonPanel, BorderLayout.CENTER); frame.pack(); frame.setVisible(true); } /** * Create the main frame's menu bar. * The frame that the menu bar should be added to. */ private void makeMenuBar(JFrame frame) { final int SHORTCUT_MASK = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(); JMenuBar menubar = new JMenuBar(); frame.setJMenuBar(menubar); JMenu menu; JMenuItem item; // create the File menu menu = new JMenu("File"); menubar.add(menu); // create the Quit menu with a shortcut "Q" key. item = new JMenuItem("Quit"); item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Q, SHORTCUT_MASK)); item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { quit(); } }); menu.add(item); // Adds an about menu. menu = new JMenu("About"); menubar.add(menu); // Displays item = new JMenuItem("Calculator Project"); item.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { showAbout(); } }); menu.add(item); } }

    Read the article

  • error: switch quantity not an integer

    - by nikeunltd
    I have researched my issue all over StackOverflow and multi-google links, and I am still confused. I figured the best thing for me is ask... Im creating a simple command line calculator. Here is my code so far: const std::string Calculator::SIN("sin"); const std::string Calculator::COS("cos"); const std::string Calculator::TAN("tan"); const std::string Calculator::LOG( "log" ); const std::string Calculator::LOG10( "log10" ); void Calculator::set_command( std::string cmd ) { for(unsigned i = 0; i < cmd.length(); i++) { cmd[i] = tolower(cmd[i]); } command = cmd; } bool Calculator::is_legal_command() const { switch(command) { case TAN: case SIN: case COS: case LOG: case LOG10: return true; break; default: return false; break; } } the error i get is: Calculator.cpp: In member function 'bool Calculator::is_trig_command() const': Calculator.cpp: error: switch quantity not an integer Calculator.cpp: error: 'Calculator::TAN' cannot appear in a constant-expression Calculator.cpp: error: 'Calculator::SIN' cannot appear in a constant-expression Calculator.cpp: error: 'Calculator::COS' cannot appear in a constant-expression The mighty internet, it says strings are allowed to be used in switch statements. Thanks everyone, I appreciate your help.

    Read the article

  • Recommend software: File checksum calculator

    - by Johnny W
    Hi, I'm looking for a light, fast hash/checksum calculator (eg. MD5, SHA1, etc.). I've been using HashCalc and it works fine enough, but I was wondering if there was something better. When downloading .ISOs from MS BizSpark, I've found that it's essential to check the SHA1, and I'm sure that other people have found the same... So what's the defacto, light, fast, simple app that does the job? :) Thanks for any recommendations.

    Read the article

  • .NET sendkeys to calculator

    - by user203123
    The sendkeys code below works well for Notepad but it doesn't work for Calculator. What is the problem? (It's another problem compared to what I sent here http://stackoverflow.com/questions/2604486/c-sendkeys-problem) [DllImport("user32.dll", CharSet = CharSet.Unicode)] public static extern IntPtr FindWindow(string lpClassName,string lpWindowName); [DllImport("User32")] public static extern bool SetForegroundWindow(IntPtr hWnd); private void button1_Click(object sender, EventArgs e) { IntPtr calculatorHandle = FindWindow("SciCalc", "Calculator"); //IntPtr calculatorHandle = FindWindow("Notepad", "Untitled - Notepad"); if (calculatorHandle == IntPtr.Zero) { MessageBox.Show("Calculator is not running."); return; } SetForegroundWindow(calculatorHandle); System.Threading.Thread.Sleep(1000); SendKeys.SendWait("111*11="); //SendKeys.SendWait("{ENTER}"); //cnt++; SendKeys.Flush(); }

    Read the article

  • C# sendkeys to calculator

    - by user203123
    The sendkeys code below works well for Notepad but it doesn't work for Calculator. What is the problem? (It's another problem compared to what I sent here http://stackoverflow.com/questions/2604486/c-sendkeys-problem) [DllImport("user32.dll", CharSet = CharSet.Unicode)] public static extern IntPtr FindWindow(string lpClassName,string lpWindowName); [DllImport("User32")] public static extern bool SetForegroundWindow(IntPtr hWnd); private void button1_Click(object sender, EventArgs e) { IntPtr calculatorHandle = FindWindow("SciCalc", "Calculator"); //IntPtr calculatorHandle = FindWindow("Notepad", "Untitled - Notepad"); if (calculatorHandle == IntPtr.Zero) { MessageBox.Show("Calculator is not running."); return; } SetForegroundWindow(calculatorHandle); System.Threading.Thread.Sleep(1000); SendKeys.SendWait("111*11="); //SendKeys.SendWait("{ENTER}"); //cnt++; SendKeys.Flush(); }

    Read the article

  • Run Calculator in my App

    - by user
    I want to start the android calculator activity IN my activity. So, I can run an activity of my app in an activity of my app. But if I want to start an activity of the calculator for example in my app, logcat throws me this: FATAL EXCEPTION: main java.lang.RuntimeException: Unable to start activity ComponentInfo{}: java.lang.SecurityException: Requesting code from com.android.calculator2 (with uid 10016) to be run in process (with uid 10044) Caused by: java.lang.SecurityException: Requesting code from com.android.calculator2 (with uid 10016) to be run in process (with uid 10044) How can I reach my goal to start the calculator activity in my activity? Thank you very much

    Read the article

  • How to open android calculator buit-in-application

    - by Jobayer
    Hello Developers Thanks to every on to support android development forum. I want to make a application where when I click a button in my application then open android built-in Calculator application. That means I want to call calculator apk file from my application. Is it possible? Advanced thanks to reply

    Read the article

  • How to use multiple variables in time calculator c#

    - by Peter O'Dwyer
    I am building a video time calculator and need to use the number of frames instead of milliseconds. e.g 25FPS HH:MM:SS:FR 00:00:10:24 <-- Last frame of 10 seconds 00:00:11:00 <-- First frame of 11 seconds My problem is that if the start frames are lower than my end frames it can't calculate the time. 00:00:10:05 <-- Start 01:00:10:10 <-- End 00:59:59:05 <-- Answer which I can't get!! HERE'S MY CODE string Startdate = Dur_txtStart.Text; string Enddate = Dur_txtEnd.Text; string Startdate1 = Startdate.Substring(0, 8); int Startframe1 = Convert.ToInt32(Startdate.Substring(9, 2)); string Startdate2 = Enddate.Substring(0, 8); int Startframe2= Convert.ToInt32(Enddate.Substring(9, 2)); TimeSpan diff = DateTime.Parse(Startdate2).Subtract(DateTime.Parse(Startdate1)); int frameDiff = Startframe2 - Startframe1; int Hour = Convert.ToInt32(diff.Hours); int Min = Convert.ToInt32(diff.Minutes); int Sec = Convert.ToInt32(diff.Seconds); if (frameDiff < 0 && Sec > 0) { Sec -= 1; string frameDiffBuild = string.Format("{0}:{1}:{2}:{3}",Hour.ToString("D2"), Min.ToString("D2"), Sec.ToString("D2"), (Convert.ToInt32(Dur_txtFPS.Text + frameDiff)).ToString("D2")); Dur_txtOutTime.Text = frameDiffBuild; } else { string frameDiffBuild = string.Format("{0}:{1}:{2}:{3}",Hour.ToString("D2"), Min.ToString("D2"), Sec.ToString("D2"), frameDiff.ToString("D2")); Dur_txtOutTime.Text = frameDiffBuild; } Hope you can help guys my head is mashed!

    Read the article

  • Creating a Skill Calculator for Runescape

    - by USDblades
    I am beginning C++. I have a long way to go and I am one to never stop learning. I want to create a project for myself that will allow me to learn as I go. It will also give me the motivation and possibly add to my portfolio when I graduate. The runescape skill calculator will ask for your current experience in the current skill of your choosing and your desired level. For Example: my woodcutting experience is 60 and I want to get to lvl 5 which is 120 exp. That means im 60 experience away. by cutting oak logs I get 5 experience per log. The calculator would tell me I need to cut 12 Oak logs. All these numbers are made up. So to my question. Where would I even begin? Hoping it would have buttons to press.

    Read the article

  • C++ stack for multiple data types (RPN vector calculator)

    - by Arrieta
    Hello: I have designed a quick and basic vector arithmetic library in C++. I call the program from the command line when I need a rapid cross product, or angle between vectors. I don't use Matlab or Octave or related, because the startup time is larger than the computation time. Again, this is for very basic operations. I am extending this program, and I will make it work as an RPN calculator, for operations of the type: 1 2 3 4 5 6 x out: -3 6 -3 (give one vector, another vector, and the "cross" operator; spit out the cross product) The stack must accept 3d vectors or scalars, for operations like: 1 2 3 2 * out: 2 4 6 The lexer and parser for this mini-calculator are trivial, but I cannot seem to think of a good way for creating the internal stack. How would you create a stack of for containing vectors or doubles (I rolled up my own very simple vector class - less than one hundred lines and it does everything I need). How can I create a simple stack which accepts elements of class Vector or type double? Thank you.

    Read the article

  • What is the fastest MD5 sum calculator?

    - by netvope
    I tested the speed of md5sum on a few Ubuntu 8.04 servers Pentium III 700 MHz: 52 MB/s Atom 1.6 GHz, 32-bit: 119 MB/s Core 2 (Yorkfield) 2.5GHz, 32-bit: 194 MB/s Core 2 (Yorkfield) 2.5GHz, 64-bit: 222 MB/s Then I downloaded a tool (by apt-get install) called md5deep and found that it's roughly 20% faster (as tested on the 32-bit Core 2 server). This makes me feel that the "vanilla" md5sum included in Ubuntu isn't the fastest one. Questions: Other than md5deep, are you aware of any MD5 calculators that are potentially faster than md5sum? (Answers for software from other OS are also welcomed.) If I want to compile md5sum myself, where can I download the source? What compiler options would you suggest for the Core 2 server? (note: gcc 4.2.4 in Ubuntu 8.04 does not seem to support -march=core2)

    Read the article

  • NetFlow Storage Calculator

    - by javano
    I am planning to deploy a NetFlow server (using NfSen/NfDump) for harvesting data from Cisco devices; Are there standard calculations or guidelines I can use to calculate my server requirements, specifically I need to plan for storage. Is there a way of knowing how much data I will collect per day for example, given N flows? Lets say one device has 10k flows per day, this is typically XYZ MBs, so I can scale this up? If not, how many flows are you guys and girls recording per day, and how much data is this generating? Hopefully we can generate an estimate from everyone else's figures! P.S. If it makes a difference, I'll be collecting from <= 50 devices max (non more than 50Mbps each).

    Read the article

  • Simple command line calculator

    - by ldigas
    Had one years ago (on Win 3.1 or '95, I'm not sure). Anyways, it was a really simple program. Stood somewhere in PATH and enabled you to do something of a kind calc 5 + 28.3*sqrt(12) and it spit out the result. Anyone know of any such these days? Doesn't need to do anything fancy ... maybe it would just be nice if it had support for exponentials, but that's it. Anyone? p.s. Not interested in full blown solutions like Python or MATLAB.

    Read the article

  • Freeware Programmer Calculator

    - by AdamC
    There have been lots of times in the past where a good programmer-oriented calculator would've saved me a lot of time. Lately, I've been doing quite a lot of bit manipulation, and having to do build/run to debug my calculations feels really slow. I've looked for something like this in the past, but found nothing that worked very well. The only thing that comes close is this one from AnalogX, but I can't get it to work or really do anything on my vista box which is where I'm doing most of my work at the moment. (btw - please send comments about my vista usage here;). Anyway, I'm looking for something for simple calculations using a C-like syntax with support for proper precenedce, operators, etc. Bonus points for cross-platform. The python interpreter was a great idea and is totally cross-platform. For windows only SpeQ is amazing. Thanks for the suggestions.

    Read the article

  • Looking for calculator source code, BSD-licensed

    - by Horace Ho
    I have an urgent project which need many functions of a calculator (plus a few in-house business rule formulas). As I won't have time to re-invent the wheel so I am looking for source code directly. Requirements: BSD licensed (GPL won't help) in c/c++ programming language 32-bit CPU minimum dependency on platform API/data structure best with both RPN and prefix notation supported emulator/simulator code also acceptable (if not impossible to add custom formula) with following functions (from wikipedia) Scientific notation for calculating large numbers floating point arithmetic logarithmic functions, using both base 10 and base e trigonometry functions (some including hyperbolic trigonometry) exponents and roots beyond the square root quick access to constants such as pi and e plus hexadecimal, binary, and octal calculations, including basic Boolean math fractions optional statistics and probability calculations complex numbers programmability equation solving

    Read the article

  • Use case modelling for calculator

    - by kyrogue
    hi, i need help modelling a use case diagram from a topic, it will be in java GUI Design a Calculator that 1.Allow user to key in a legitimate arithmetic statement that involves number, operator +, - and bracket '(' and ')' ; 2.When user press “Calculate” button, display result; 3.Some legitimate statement would be ((3+2)-4+2) (equals 3) and (-2+3)-(3-1) (equals -1); 4.You should NOT use a pre-existing function that just take in the statement as a parameter and returns the result but you should write the logic of parsing every character in your code. 5.Store the last statement and answer so it is displayed when user press the “Last calculation” button. i have designed two use case diagrams using UML on netbeans 6.5.1, one of the use case i am not sure whether is it containing too much use cases etc, while the other is what i think could be too vague for the topic.i hope to get some feedback on whether the use case diagram are appropriate, thanks.

    Read the article

  • Simple addition calculator in python

    - by Krysten
    I built a very simple addition calculator in python: #This program will add two numbers entered in by the user print "Welcome!" num1 = input("Please enter in the first number to be added.") num2 = input("Please enter in the second number to be added.") sum = num1 + num2 print "The sum of the two numbers entered is: ", sum I haven't setup python yet, so I'm using codepad.org (an online compiler). I get the following error: Welcome! Please enter in the first number to be addeded.Traceback (most recent call last): Line 5, in num1 = input("Please enter in the first number to be addeded.") EOFError

    Read the article

  • JQuery Calculator not working

    - by user2798091
    I am trying to build a tile calculator but can't seem to get the following code to work: JQuery: $(document).ready( function caculateForm() { var length = document.getElementById('length').value; var width = document.getElementById('width').value; var size = document.getElementById('size').value; var compute = (length * width) / (size / 100); var total = compute * 100; var allowance = (compute * 100) * .10; allowance = Math.floor(total) + Math.floor(allowance + 1); document.getElementById('total').value = Math.floor(total); document.getElementById('allowance').value = allowance; } }); $(document).ready( function clearFileInput(id) { var elem = document.getElementById(id); elem.parentNode.innerHTML = elem.parentNode.innerHTML; } }); Here is my jsfiddle

    Read the article

  • Java Simple Calculator

    - by Lahiru Kavinda
    I have made this calculator program in Java. This works well only when two numbers are calculated at one time. That means to get the sum of 1+2+3 you have to go this way : press 1 press + press 2 press = press + press 3 press = and it calculates it as 6. But I want to program this so that I can get the answer by: press 1 press + press 2 press + press 3 press = but this gives the answer 5!!! How to code this so that it works like an ordinary calculator? Here is my code: import java.awt.*; import java.awt.event.*; import javax.swing.*; public class cal1 extends JFrame { double op1 = 0d, op2 = 0d; double result = 0d; char action; boolean b = false; boolean pressequal = false; public cal1() { makeUI(); } private void makeUI() { setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setSize(400, 400); b0 = new JButton("0"); b1 = new JButton("1"); b2 = new JButton("2"); b3 = new JButton("3"); b4 = new JButton("4"); b5 = new JButton("5"); b6 = new JButton("6"); b7 = new JButton("7"); b8 = new JButton("8"); b9 = new JButton("9"); bDot = new JButton("."); bMul = new JButton("*"); bDiv = new JButton("/"); bPlus = new JButton("+"); bMinus = new JButton("-"); bEq = new JButton("="); t = new JTextField(12); t.setFont(new Font("Tahoma", Font.PLAIN, 24)); t.setHorizontalAlignment(JTextField.RIGHT); numpad = new JPanel(); display = new JPanel(); numpad.add(b7); numpad.add(b8); numpad.add(b9); numpad.add(bMul); numpad.add(b4); numpad.add(b5); numpad.add(b6); numpad.add(bDiv); numpad.add(b1); numpad.add(b2); numpad.add(b3); numpad.add(bMinus); numpad.add(bDot); numpad.add(b0); numpad.add(bEq); numpad.add(bPlus); numpad.setLayout(new GridLayout(4, 5, 5, 4)); display.add(t); add(display, BorderLayout.NORTH); add(numpad, BorderLayout.CENTER); t.addKeyListener(new KeyAdapter() { @Override public void keyTyped(KeyEvent e) { typeOnt(e); } }); b0.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { b0pressed(e); } }); b1.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { b1pressed(e); } }); b2.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { b2pressed(e); } }); b3.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { b3pressed(e); } }); b4.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { b4pressed(e); } }); b5.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { b5pressed(e); } }); b6.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { b6pressed(e); } }); b7.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { b7pressed(e); } }); b8.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { b8pressed(e); } }); b9.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { b9pressed(e); } }); bDot.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { bDotpressed(e); } }); bPlus.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { bPlusPressed(e); } }); bMinus.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { bMinusPressed(e); } }); bMul.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { bMulPressed(e); } }); bDiv.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { bDivPressed(e); } }); bEq.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { bEqpressed(e); } }); } void typeOnt(KeyEvent e) { e.consume(); } void b0pressed(ActionEvent e) { if (b) { t.setText(null); b = false; t.setText(t.getText() + "0"); } else { t.setText(t.getText() + "0"); } } void b1pressed(ActionEvent e) { if (b) { t.setText(null); b = false; t.setText(t.getText() + "1"); } else { t.setText(t.getText() + "1"); } } void b2pressed(ActionEvent e) { if (b) { t.setText(null); b = false; t.setText(t.getText() + "2"); } else { t.setText(t.getText() + "2"); } } void b3pressed(ActionEvent e) { if (b) { t.setText(null); b = false; t.setText(t.getText() + "3"); } else { t.setText(t.getText() + "3"); } } void b4pressed(ActionEvent e) { if (b) { t.setText(null); b = false; t.setText(t.getText() + "4"); } else { t.setText(t.getText() + "4"); } } void b5pressed(ActionEvent e) { if (b) { t.setText(null); b = false; t.setText(t.getText() + "5"); } else { t.setText(t.getText() + "5"); } } void b6pressed(ActionEvent e) { if (b) { t.setText(null); b = false; t.setText(t.getText() + "6"); } else { t.setText(t.getText() + "6"); } } void b7pressed(ActionEvent e) { if (b) { t.setText(null); b = false; t.setText(t.getText() + "7"); } else { t.setText(t.getText() + "7"); } } void b8pressed(ActionEvent e) { if (b) { t.setText(null); b = false; t.setText(t.getText() + "8"); } else { t.setText(t.getText() + "8"); } } void b9pressed(ActionEvent e) { if (b) { t.setText(null); b = false; t.setText(t.getText() + "9"); } else { t.setText(t.getText() + "9"); } } void bDotpressed(ActionEvent e) { if (!t.getText().contains(".")) { if (b) { t.setText(null); b = false; t.setText(t.getText() + "0."); } else if (t.getText().isEmpty()) { t.setText("0."); } else { t.setText(t.getText() + "."); } } } void bPlusPressed(ActionEvent e) { b = true; action = '+'; op1 = Double.parseDouble(t.getText()); } void bMinusPressed(ActionEvent e) { b = true; action = '-'; op1 = Double.parseDouble(t.getText()); } void bMulPressed(ActionEvent e) { b = true; action = '*'; op1 = Double.parseDouble(t.getText()); } void bDivPressed(ActionEvent e) { b = true; action = '/'; op1 = Double.parseDouble(t.getText()); } void bEqpressed(ActionEvent e) { op2 = Double.parseDouble(t.getText()); doCal(); } void doCal() { switch (action) { case '+': result = op1 + op2; break; case '-': result = op1 - op2; break; case '*': result = op1 * op2; break; case '/': result = op1 / op2; break; } t.setText(String.valueOf(result)); } public static void main(String[] args) { new cal1().setVisible(true); } JButton b0; JButton b1; JButton b2; JButton b3; JButton b4; JButton b5; JButton b6; JButton b7; JButton b8; JButton b9; JButton bDot; JButton bPlus; JButton bMinus; JButton bMul; JButton bDiv; JButton bEq; JPanel display; JPanel numpad; JTextField t; }

    Read the article

  • how can i handle calculator buutons in c# window form program

    - by sama
    using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace lab8ass1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button11_Click(object sender, EventArgs e) { textBox1.Text += "."; } private void btnone_Click(object sender, EventArgs e) { textBox1.Text += "1"; } private void btnrwo_Click(object sender, EventArgs e) { textBox1.Text += "2"; } private void btnthree_Click(object sender, EventArgs e) { textBox1.Text += "3"; } private void btnfour_Click(object sender, EventArgs e) { textBox1.Text += "4"; } private void btnfive_Click(object sender, EventArgs e) { textBox1.Text += "5"; } private void btnsix_Click(object sender, EventArgs e) { textBox1.Text += "6"; } private void btnseven_Click(object sender, EventArgs e) { textBox1.Text += "7"; } private void btneight_Click(object sender, EventArgs e) { textBox1.Text += "8"; } private void btnnine_Click(object sender, EventArgs e) { textBox1.Text += "9"; } private void btnzero_Click(object sender, EventArgs e) { textBox1.Text += "0"; } string s1,s; private void btnplus_Click(object sender, EventArgs e) { s1 = textBox1.Text; textBox1.Text = ""; s = textBox1.Text; //textBox1.Text } private void btnequal_Click(object sender, EventArgs e) { } } } here my code how can i handle calculator buutons

    Read the article

  • [Python] Tips for making a fraction calculator code more optimized (faster and using less memory)

    - by Logic Named Joe
    Hello Everyone, Basicly, what I need for the program to do is to act a as simple fraction calculator (for addition, subtraction, multiplication and division) for the a single line of input, for example: -input: 1/7 + 3/5 -output: 26/35 My initial code: import sys def euclid(numA, numB): while numB != 0: numRem = numA % numB numA = numB numB = numRem return numA for wejscie in sys.stdin: wyjscie = wejscie.split(' ') a, b = [int(x) for x in wyjscie[0].split("/")] c, d = [int(x) for x in wyjscie[2].split("/")] if wyjscie[1] == '+': licz = a * d + b * c mian= b * d nwd = euclid(licz, mian) konA = licz/nwd konB = mian/nwd wynik = str(konA) + '/' + str(konB) print(wynik) elif wyjscie[1] == '-': licz= a * d - b * c mian= b * d nwd = euclid(licz, mian) konA = licz/nwd konB = mian/nwd wynik = str(konA) + '/' + str(konB) print(wynik) elif wyjscie[1] == '*': licz= a * c mian= b * d nwd = euclid(licz, mian) konA = licz/nwd konB = mian/nwd wynik = str(konA) + '/' + str(konB) print(wynik) else: licz= a * d mian= b * c nwd = euclid(licz, mian) konA = licz/nwd konB = mian/nwd wynik = str(konA) + '/' + str(konB) print(wynik) Which I reduced to: import sys def euclid(numA, numB): while numB != 0: numRem = numA % numB numA = numB numB = numRem return numA for wejscie in sys.stdin: wyjscie = wejscie.split(' ') a, b = [int(x) for x in wyjscie[0].split("/")] c, d = [int(x) for x in wyjscie[2].split("/")] if wyjscie[1] == '+': print("/".join([str((a * d + b * c)/euclid(a * d + b * c, b * d)),str((b * d)/euclid(a * d + b * c, b * d))])) elif wyjscie[1] == '-': print("/".join([str((a * d - b * c)/euclid(a * d - b * c, b * d)),str((b * d)/euclid(a * d - b * c, b * d))])) elif wyjscie[1] == '*': print("/".join([str((a * c)/euclid(a * c, b * d)),str((b * d)/euclid(a * c, b * d))])) else: print("/".join([str((a * d)/euclid(a * d, b * c)),str((b * c)/euclid(a * d, b * c))])) Any advice on how to improve this futher is welcome. Edit: one more thing that I forgot to mention - the code can not make use of any libraries apart from sys.

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >