Hi people, I am currently teaching myself C++ with Stroustrup's "Programming, Principles and Practice using C++" and I'm stuck on one of the in-book exercises. It is a chunk of code (~180 lines) of buggy code that, when debugged properly, should create a calculator program. I have reached the limits of my ability and need some more help. There are 8 bugs in total, 5 syntax and 3 logic. I have debugged the syntax errors and now need help with the logic. I think I got one of the logic, so there *should* only be 2 left. Any help would …

Member Avatar
Member Avatar
+0 forum 12

Hello DaniWeb Community, I'm making an online store and am wanting make a way to calculate the shipping the way I've got it at the moment is using [this](https://developers.auspost.com.au/apis/pac/getting-started). However, it isn't good for multiple items. So if one item is $10 and another (smaller) item is $5, so the total is (obviously) $15. Only thing is, you could probably fit both items in a satchel and only have to pay the $10 (or so). So how do I go about doing this? like how do other online stores do it? I would rather not have customers pay for more …

Member Avatar
Member Avatar
+0 forum 3

Hi I'm trying to find a script that will allow me to set multiple options eg. option 1 = 40, option 2 = 15, option 3 = 30 etc where the user can select any number of the options and it will total the numbers up for them example there are 10 options, the user only selects 5 of them the calculator will add up the value of just those 5 options and the user can add from the other options or remove from the currently selected options and it will change the added up value of the total

Member Avatar
Member Avatar
+0 forum 6

Hello, it is me once more. I am using Python 2.3, and I must use Zelle's graphics class (and I must agree with many of you. Tkinter is much better). We have been tasked with creating a Graphical Scientific Calculator. In addition to the normal operators, it must contain the following buttons: log - base 10 of display ln - base e of display exp - e to the display power sin - sine of display in radians cos - cosine of display in radians tan - tangent of display in radians sqrt - square root of display 1/x - …

Member Avatar
Member Avatar
+0 forum 25

I am trying to make a calculator, but I can not seem to figure out how to get the = operation to work. Everything else seems to be working fine, but I am just really struggling with the =. Any guidance in the right direction would be super helpful! import javax.swing.JFrame; import javax.swing.JTextField; import javax.swing.JPanel; import javax.swing.JLabel; import javax.swing.JButton; import java.awt.BorderLayout; import java.awt.GridLayout; import java.awt.Color; import java.awt.event.ActionListener; import java.awt.event.ActionEvent; public class Calculator extends JFrame implements ActionListener { public static final int WIDTH = 400; public static final int HEIGHT = 400; public static final int NUMBER_OF_DIGITS = 30; JTextField jb …

Member Avatar
Member Avatar
+0 forum 1

Hello, i faced some problem in building the android calculator. The problems like this: 1) If i click 2 + 3, it worked well, and screen will show the 5.** BUT! **when i clicked + and + and + and +...... it will continuosly add the answer. How can i solve it 2) if i click 2 + 3, it worked well, and screen will show the 5. **BUT!** how if i 2 + - , it will perform 2 + 2 - .... Others doesnt have any problem, anyone may help MainActivity.java file import java.text.DecimalFormat; import android.app.Activity; import android.os.Bundle; …

Member Avatar
Member Avatar
+0 forum 2

It could be simplifide more, I know. I was doing it as an exersise so its rough and skecthy. But it's workable, I tested it more then 50 times.

Member Avatar
Member Avatar
+0 forum 3

This is the updated version of the Tiny Tkinter Calculator. It has more power, since you can type in functions contained in the Python math module then press the equals key. You can then move the result into memory for other calculations. The code is written in OOP class style as an exercise, still simple and hopefully very readable. Again, you are welcome to improve the functionality, but don't turn it into a HUGE calculator.

Member Avatar
Member Avatar
+4 forum 8

I needed a calculator and I didn't want to use google since my internet is slow. So I made one! Here it is. Working with it is simple. Use the number and operation keys("c" for clear, "p" for pi, and "s" for sqrt) as well as the return and enter key, for equals, or just use the button gui! Hope you like it! The only thing I would really like to work on is the gui. If some one would help me on that that would be greatly appreciated. I will be adding more operations, fixing the power button, and …

Member Avatar
+0 forum 0

Hello everyone. I recently started using C++ and blah blah blah you know the rest. Using my extremely limited knowledge, I attempted to make a basic 4 function calculator CUI in C++. The code I wrote is as follows. [CODE]#include <iostream> #include <string> #include <sstream> using namespace std; char operator -; char operator +; char operator *; char operator /; int myoperator; float num1; float num2; float result; int mainproc () { cout << "Welcome to the 4-Basic-Calculator!\nEnter first number: "; cin >> num1; cout << "\nEnter the operator: "; cin >> operator; if(operator == "+") myoperator = 1; if(operator …

Member Avatar
Member Avatar
-2 forum 16

Hello, I have read the requirements of this challenge and I have a good understanding of what needs to be done. I am confident that my program works but it DOESN'T. What a blow to my confidence. I am in hopes that someone kind person would point me in the right direction. I also have a web link where you can see my faults. http://www.dianamagers.com/folio/_income_tax/index.html Thank you very much in advance. I am gratefully appreciative. <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Income Tax Calculator</title> <style> article, aside, figure, footer, header, nav, section { display: block; } body { font-family: Arial, …

Member Avatar
Member Avatar
+0 forum 2

i need help creating an pplication to calculate flooring costs. The application should allow the user to enter the room length and width in metres, and select a type of flooring from a set of radio buttons (see Figure 1). The program should include the costs for the different types of flooring available. The flooring comes in packs which each cover 2m2. The price per pack is as follows: Beech £25 Maple £30 Tile £20 Laminate £10 When the user clicks on the “Calculate cost” button the program should validate the input (see below) and display a quotation, suitably formatted, …

Member Avatar
Member Avatar
+0 forum 5

hi thier i was wondering if you guys could hep me when i press equall it calculates but when i press equall again it adds the first number added, for example if i was to enter 3 + 2 = 5 if i press enter again it equalls to 8 instead of 7 import java.awt.*; // Use the awt library import java.awt.event.*; import java.awt.geom.*; import javax.swing.*; // Use the swing library import java.util.Random; // Get random numbers import java.util.Scanner; import java.lang.Number.*; // Need this for Integer import java.lang.Math.*; // The Moving Component class is a subclass of JComponent and defines …

Member Avatar
+0 forum 0

Hi, i have just started programming with python and i have beken given a task where i must create a python calculator. So far i have created the code (seen below) however i need help explaining it-e.g. saying what each part of the code does: from tkinter import * root = Tk() root.title("Python Calculator") button_layout_Design = [ "1","2","3","+", "4","5","6","-", "7","8","9","*", "C","0","=","/" ] r = 1 c = 0 for buttons in button_layout_Design: cmd = lambda key=buttons: onClick(key) Button(root,text=buttons,relief="flat",command=cmd).grid(row=r,column=c) c += 1 if c > 3: r += 1 c = 0 view = Entry(root) view.grid(row=0,column=0,columnspan=4) def onClick(key): if key == …

Member Avatar
Member Avatar
+0 forum 5

what im gonna do if two Jtexfield numbers in the calculator? how can i command all buttons numbers put to second textfield?:) -java

Member Avatar
Member Avatar
+0 forum 1

Hi, First of all, I'm a newbeginner in C++. Ok, basically I'm tring to make a calculator with functions. Every function calculates either addition, subtraction, division or multiplication, pretty simple. Though I can't get it to call these functions! Here, take a look at my code: #include <iostream> using namespace std; // Prototyping the functions int addition(int n1, int n2); int subtract(int n1, int n2); int division(int n1, int n2); int multiply(int n1, int n2); // Main int main() { // Input, choice cout << "What do you want to calculate?\n" << endl; cout << "Addition (1)" << endl; cout …

Member Avatar
Member Avatar
+0 forum 16

Can anyone help me with this homework assignment. Im so confused!!! Create a very simple four function integer calculator with buttons for Add, Subtract, Multiply, and Divide, and with two text-type input fields. When the user enters two numbers and clicks one of the buttons, the answer is displayed where shown. Your program must use an alert to tell the user about any errors. The possible errors include: One or both input fields are blank One or both input fields < -9999 or greater than 9999 Divide by zero Illegal character in either input field. Only 0, 1 ,2 ,3 …

Member Avatar
Member Avatar
+0 forum 1

Good time of day! I'm working on creating an Eulers Method Calculator program. The problem I got stuck on is I don't know how to convert the user's string into a Differential Equation (dy/dx). This is what I have so far: import static java.lang.System.*; import java.util.Scanner; class EulersMethod { public static void main(String args[]) { double xcor, ycor, delx, dely, xcorplusdelx, ycorplusdely, fx; String dydx; Scanner input = new Scanner(System.in); out.print(" Enter x coordinate "); xcor = input.nextDouble(); out.print(" Enter y coordinate "); ycor = input.nextDouble(); out.print(" Enter delta x "); delx = input.nextDouble(); out.print(" Enter dy/dx "); dydx = …

Member Avatar
Member Avatar
+0 forum 5

this one is driving me nuts so I hope you guys can school me a bit. My goal is to create a multiple-option dynamic pricing sheet for a product page. The concept I have is that all the information for the product is inserted in the database via relative tables. There is one table for each product where I include the basic info (id, name, description, base cost, etc) where each item will get one row. Then the relative table is for each option available (id, pid [the id for the product in the previous table], option name [such as …

Member Avatar
Member Avatar
+0 forum 7

So I am using a while loop and my problem happens when I try and run this code in an online compiler which doesn't have input, it keep looping forever and doesn't wait for input. Is there a way I can force it to wait ? Please note that it works perfect with Code blocks ide. #include <iostream> #include <stdlib.h> int main() { system("COLOR A"); bool repeat = true; int v1 = 0, v2 = 0; std::string sum = "sum", subtract = "subtract", multiply = "multiply", divide = "divide", exponentiation = "exponentiation", squareroot = "squareroot", polynomials = "polynomials", exit = …

Member Avatar
Member Avatar
+0 forum 2

Here little debugged version of my calculator posted earlier in GUI calculator thread. I prepared it after listening that their teacher did more limited calculator in around 150 lines of code with their graphics module. This is 115 lines without empty lines and comment lines [CODE]>>> li=[i for i in open('SimplistiCalc.pyw') ... if i.strip() and not i.strip().startswith('#')] >>> len(li) 115 >>>[/CODE] Save attached gifs to same directory as the code. Comments welcome!

Member Avatar
Member Avatar
+1 forum 9

I am trying to make a calculator to calculate your age in dog years, the following is the code I have so far, minus the html portion of it <?php if (!isset($_POST['your_age']) ) { header("Location: dog_form.html"); exit; } if ($_POST['your_age'] == "your_age") { $result = ($_POST['your_age'] *7; if ($_POST['your_age'] >= 100 && $_POST['your_age'] <= 199) { $result = "An Old Dog"; } else if ($_POST['your_age'] >= 200 && $_POST['your_age'] <= 299) { $result = "Wicked Old Dog"; } else if ($_POST['your_age'] >= 300) { $result = "Ancient Dog"; } ?> <HTML> <HEAD> <TITLE>Calculation Result</TITLE> </HEAD> <BODY><H2><center> <P>The result of the …

Member Avatar
Member Avatar
+0 forum 11

Hi, how i can fix my code to support keyboard input? /* * To change this template, choose Tools | Templates * and open the template in the editor. */ package calculater1; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Font; import java.awt.GridLayout; import java.awt.event.ActionEvent; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import java.awt.Container.*; import javax.swing.Icon; import javax.swing.ImageIcon; import java.awt.event.ActionListener; /** * * @author al_khtaiob */ public class Calcu extends JFrame implements ActionListener{ final int MAX_INPUT_LENGTH = 20; final int INPUT_MODE = 0; final int RESULT_MODE = 1; final int ERROR_MODE = 2; int displayMode; boolean clearOnNextDigit, percent; double lastNumber; String lastOperator …

Member Avatar
Member Avatar
+0 forum 6

Hello, I have this calculator program that compiles and runs just fine, but my loop will not break as intendend too, when I hit 5 it it still runs the options to enter a number, here is my code: import java.util.Scanner; public class calculator { public static void main(String[] args) { int i = 0; do { Scanner s = new Scanner(System.in); System.out.println("-Easy Calculator-"); System.out.println("1) Add"); System.out.println("2) Subtract"); System.out.println("3) Multiply"); System.out.println("4) Divide"); System.out.println("5) Exit"); System.out.println(" "); System.out.println("Enter Option: "); i = s.nextInt(); System.out.println("First Number: "); int a = s.nextInt(); System.out.println(" "); System.out.println("Your first number number is " +a); System.out.println(" "); …

Member Avatar
Member Avatar
+0 forum 3

i want to use uize's calculator in my website i am trying it for three days but can't it how to use it. Please if anyone can tell me how to use it then please let me know as soon as possible.

Member Avatar
Member Avatar
+0 forum 1

I was given a question from my college's e-learning blackboard: > Write a program that will act as a simple calculator. It should ask the user for a floating point number, an operator, and another floating point number. The program should first check the operator is either ‘+’, ‘-‘, or ‘*’. If it is, then it should output the result of performing the operation on the two floating point numbers. If the operator is not a ‘+’, ‘-‘, or ‘*’ the program should print the message “Illegal operation!” > Sample input and output: > Enter a number: 10 > Enter …

Member Avatar
Member Avatar
+0 forum 5

Hello how can i make a change calculator? for exmaple i want to buy an item thet cost 5.89$ and in canada no more 1 cents so how can round the number to 5.90?

Member Avatar
Member Avatar
+0 forum 3

Hello, I have been trying to figure out how to make an array work with a calculator that uses up to 100 different inputs to calculate sum, difference, standard deviation min max etc. When I try to compile the code I get (error: no match for 'operator<<' on line 64 being max=arrayVal[i]'. I've only done very basic concepts with arrays till now where I would ask for individual input for a 4 or 5 element array. So i do not know if I am using the interger and for statements in this properly. Thank you all for the help in …

Member Avatar
Member Avatar
+0 forum 7

Hello, I have been messing around and writing more and more intricate calculator programs on MVE C++. The issue I am having right now is my program is not running unless I give my add, sub, etc. a value. When I try to just leave them as int add; or int sub; It will not do the equation. Also, if I try to have my couts of cout<<"Your sum...<<add will not appear unless in the do-while loop. Lastly, if I hit q or Q it causes the program to output alot of random things, even though I made my while …

Member Avatar
Member Avatar
+0 forum 7

Hello, I am new to C++ and I was trying to write a simple calculator program that has a do-while loop and also includes a series of != statements. Even though I make the statements with all the appropriate keystrokes it keeps giving me my invalid sign statement. Also, I would like to know if I used the "while" statement properly. Thank you for your help in advance =D! #include <iostream> #include <math.h> #include <string> using namespace std; int result,value; char sign; int main() { result = 0; do { cout<< "Current value is "<<result<<endl; cout<< "Please enter an operation …

Member Avatar
Member Avatar
+0 forum 8

The End.