473,386 Members | 2,042 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

BMI Calculator with GUI

18
Alright.. I have the basic interface of the Body Mass Index worked out. However, I dont know how to get the feet,inches, and weight to be be multiplied:
Expand|Select|Wrap|Line Numbers
  1. (w / (h * 12 + x) * (h * 12 + x)) * 703)
Here is my code for the BMI Calculator:
Expand|Select|Wrap|Line Numbers
  1. from graphics import *
  2. from math import *
  3. def main():
  4.     win = GraphWin("BMI Calculator", 800, 600)
  5.     win.setCoords(-2.0, -2.0, 11, 11.5)
  6.     Text(Point(5,5), "Feet:").draw(win)
  7.     Text(Point(5,3), "Inches:").draw(win)
  8.     Text(Point(5,1), "Weight:").draw(win)
  9.     h = Entry(Point(7,5), 5)
  10.     h.setText("0")
  11.     h.draw(win)
  12.     x = Entry(Point(7,3), 5)
  13.     x.setText("0")
  14.     x.draw(win)
  15.     w = Entry(Point(7,1), 5)
  16.     w.setText("0")
  17.     w.draw(win)
  18.  
  19.    # Create Function Box
  20.     Text(Point(3, 0), "BMI").draw(win)
  21.     stng = Entry(Point(4,0), 7)
  22.     stng.setText("0")
  23.     stng.draw(win)
  24.  
  25.     output = Entry(Point(4,1), "" )
  26.     output.draw(win)
  27.     button = Text(Point(1.5,2.0), "Convert")
  28.     button.draw(win)
  29.     Rectangle(Point(1,1.5), Point(2,2.5)).draw(win)
  30.  
  31.     ## wait for a mouse click
  32.     win.getMouse()
  33.  
  34.     ## convert input
  35.     h =  float(eval(h.getText()))
  36.     x =  float(eval(x.getText()))
  37.     w =  float(eval(w.getText()))
  38.  
  39.  
  40.  
  41.  
  42.  
  43.     ## display output and change button
  44.     BMI
  45.  
  46.  
  47.     ## wait for click and then quit
  48.     win.getMouse()
  49.     win.close()
  50.  
  51.     main()
  52.  
So I guess I now prompt my question.. How can I get an output box that (using the calculation that I put above) "prints" the answer..
Mar 14 '07 #1
0 1577

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: mwh | last post by:
Hi. If you remember, I posted Expressons Help. Now I am making a calculator with javascript. I can't get this to work: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"...
6
by: Rafael | last post by:
Hi Everyone, I need some help with my calculator program. I need my program to do 2 arguments and a 3rd, but the 3rd with different operators. Any help would be great. Here is my code.... ...
3
by: Paul | last post by:
I want to make a simple calculator program but dont know where to get started. This is not GUI but a simple terminal program. It would get input like this Enter number: 5 + 10
3
by: Art | last post by:
Hi, In part of my application the user may need to do a simple arithmetic calculation in order to get the value to put in a text box. I was thinking that it would be good if I could display the...
3
by: PieMan2004 | last post by:
Hi, ive been looking for a solid java community to help me when im tearing out my hair :) Basically ive constructed a GUI that has to represent the same look and functions of the typical windows...
24
by: firstcustomer | last post by:
Hi, Firstly, I know NOTHING about Javascript I'm afraid, so I'm hoping that someone will be able to point me to a ready-made solution to my problem! A friend of mine (honest!) is wanting to...
19
by: TexasNewbie | last post by:
This was originally just a calculator without a decimal point. After I added the decimal, it now tells me invalid second number. //GUI Calculator Program import javax.swing.*; import...
5
Deathwing
by: Deathwing | last post by:
Hi everyone one I'm playing around with trying to make an expense calculator. I would like it so that the user can keep enter expenses until they have no more expenses. Then I would like for the...
3
by: itsmichelle | last post by:
This is a very primative code of a java swing calculator. I have assigned all the number buttons and the operator buttons and I can add, subtract, multiply, and divide two numbers together. However,...
3
by: mandy335 | last post by:
public class Calculator { private long input = 0; // current input private long result = 0; // last input/result private String lastOperator = ""; // keeps track of...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.