![]() |
![]() |
![]() |
|||||
![]() |
![]() |
![]() |
![]() |
![]() |
|||
| Welcome
to Tech Support Forum home to more then 136,000 problems solved. Issues
have included: Spyware, Malware, Virus Issues, Windows, Microsoft,
Linux, Networking, Security, Hardware, and Gaming Getting your
problem solved is as easy as: 1. Registering for a free account 2. Asking your question 3. Receiving an answer Registered members: * See fewer ads. * And much more..
|
| Want to know how to post a question? click here | Having problems with spyware and pop-ups? First Steps |
|
|||||||
| Programming A discussion forum for programs and programming used in tech-related businesses. |
![]() |
|
|
LinkBack | Thread Tools |
|
|
#1 (permalink) |
|
Henry
Join Date: Apr 2005
Posts: 3,484
OS: Mac OSX
|
Wow LOL, plenty of replies. But since then I've quit C++ (too confoozing IMO although I have the Borland Compiler now
).But *I hate to revamp this thread, I knew more then than I do now * I also see this problem in Python. In IDLE, the GUI thing, I can write something like *note I just copied and pasted off the net, I'm a noobzor at this stuff* this:Code:
# Area calculation program
print "Welcome to the Area Calculation Program!"
print "----------------------------------------"
print
# Print out the menu
print "Please choose a shape:"
print "======================"
print "1 Rectangle"
print "2 Circle"
print "3 Triangle"
print "======================"
# Recieve input
foo = input("> ")
# Start calculating
if foo == 1:
height = input("Please input the height:")
width = input("Please enter the width:")
area = height*width
print "The area is:", area
elif foo == 2:
radius = input("Please enter the radius:")
area = 3.14*(radius**2)
print "The area is:", area
elif foo == 3:
base = input("Please enter the base:")
height = input("Please enter the height:")
area = .5*height*base
print "The area is:", area
__________________
JohnThePilot: Cenedl heb iaith, cenedl heb galon (a nation without a language is a nation without a heart) John Butler Trio: Go take a step outside, see what's shakin' in the real world - Good Excuse Paul Kelly: Just add a dollop of tomato sauce for sweetness and that extra tang - How to Make Gravy |
|
|
|
| Important Information |
|
Join the #1 Tech Support Forum Today - It's Totally Free!
TechSupportForum.com is a leading support website for your computer needs. We offer free, friendly and personalized computer support. Why pay to have your computer fixed when you can do it for free. Join TechSupportforum.com Today - Click Here |
|
|
#2 (permalink) |
|
TSF Enthusiast
Join Date: Dec 2004
Posts: 604
OS: windows xp
|
That common and not just your computer. 2 things you can do so you can see the answer. one add a input statment to the end of the code. this way the program wont exit till you hit enter. two instead of double clicking on the code you can open the commond prompt up and open the program using the command prompt. this way once it finish running the command prompt will stay open.
__________________
|
|
|
|
|
|
#3 (permalink) |
|
Henry
Join Date: Apr 2005
Posts: 3,484
OS: Mac OSX
|
Oky-doky, will try.
__________________
JohnThePilot: Cenedl heb iaith, cenedl heb galon (a nation without a language is a nation without a heart) John Butler Trio: Go take a step outside, see what's shakin' in the real world - Good Excuse Paul Kelly: Just add a dollop of tomato sauce for sweetness and that extra tang - How to Make Gravy |
|
|
|
|
|
#4 (permalink) |
|
Registered User
Join Date: Mar 2005
Location: Georgia
Posts: 188
OS: WinXP SP2-Desktop + WinXP PRO- IBM Laptop
|
Actually try this...
Much easier.... Code:
def AREA_PROG():
# Area calculation program
print "Welcome to the Area Calculation Program!"
print "----------------------------------------"
print
# Print out the menu
print "Please choose a shape:"
print "======================"
print "1 Rectangle"
print "2 Circle"
print "3 Triangle"
print "======================"
# Recieve input
foo = input("> ")
# Start calculating
if foo == 1:
height = input("Please input the height:")
width = input("Please enter the width:")
area = height*width
print "The area is:", area
elif foo == 2:
radius = input("Please enter the radius:")
area = 3.14*(radius**2)
print "The area is:", area
elif foo == 3:
base = input("Please enter the base:")
height = input("Please enter the height:")
area = .5*height*base
print "The area is:", area
print " _______________________________________________________________"
AREA_PROG()
AREA_PROG()
|
|
|
|
|
|
#5 (permalink) |
|
Registered User
Join Date: Mar 2005
Location: Georgia
Posts: 188
OS: WinXP SP2-Desktop + WinXP PRO- IBM Laptop
|
This reminds me of my first program i made in python when i was first learning it...
Funny story actually, i wrote all the program and everything... And later that week i found out there was a Math module in the library.... LOL! Code:
# Funtions to USE
def line():
print
def twoline():
print
print
pi = 3.14
# help1 = input("If you would like to know how I came up with this answer. Type 911.")
# if help1 == 911:
# print "I took the length of the rectangle...", length
# print "then i took the width................", width
# print "Then multiplied......................", rect
# Modules to import
from time import sleep
def main():
# Calculater #
#_______________________________________________________________________________________
#Menu of Calculaters
def firstMenu():
print "-------------------------------------------------------"
print "What kind of calculater to you want?"
print "-------------------------------------------------------"
print "You have the choice of:"
line()
print "Area, press 1"
line()
print "Addition, press 2"
line()
print "Subtraction, press 3"
line()
print "Perimeter, press 4"
line()
print "Division, press 5"
line()
print "Multiplication, press 6"
line()
# __________________________________________________________________________________________
# Menu of Area
def areaMenu():
print "________________________________"
print "How excactly do you want it"
line()
print "Circle_1"
line()
print "Triangle_2"
line()
print "Square_3"
line()
print "Rectangle_4"
twoline()
print "________________________________"
#----------------------------------------------------------------------------------------------
# Circle Area
# ----------------------------------------------------------------------------------------------
def areaCir():
if s1 == 1:
print "You have chosen to calculate the area of a circle."
print "Formula--is--Pi-r-squared"
line()
pi = 3.14
r1 = input("What is the radius")
line()
answers1 = pi*r1
answerss1 = answers1**2
sleep(1)
print "the answer is..."
print answerss1
line()
help1 = input("If you would like to know how I came up with this answer. Type 911.")
if help1 == 911:
line()
print "I the pi.............................", pi
print "then i took the radius...............", r1
print "Then squared.........................", answerss1
#----------------------------------------------------------------------------------------------
# Triangle Area
#---------------------------------------------------------------------------------------------
def areaTri():
if s1 == 2:
# Base times hieght divided by 2
print "You have chosen to calculate the area of a triangle."
line()
print "Formula--is--Base*Height then divided by 2"
line()
baseT = input("Please define the base length of the triangle.")
heightT = input("Please define the height of the triangle")
sleep(1)
t1 = baseT*heightT
t1t = t1/2
print "the answer is..."
print t1t
line()
help1 = input("If you would like to know how I came up with this answer. Type 911.")
if help1 == 911:
print "I took the base of the triangle", baseT
print "then took the height...........", heightT
print "multiplied both together.......", t1
print "then divided my two. :)........", t1t
#----------------------------------------------------------------------------------------------------
# Square Area
# -----------------------------------------------------------------------------------------------------
def areaSqu():
if s1 == 3:
print "You have chosen to calculate the area of a square."
line()
print "Formula--is--Base*Height"
line()
baseS = input("What is the base of the square.")
heightS = input("What is the height of the square.")
sleep(1)
squareA = baseS*heightS
print "The answer is..."
print squareA
help1 = input("If you would like to know how I came up with this answer. Type 911.")
if help1 == 911:
print "First take the base of the square..", baseS
print "Then take the height of the square.", heightS
print "then multiply......................", squareA
# ----------------------------------------------------------------------------------
# Rectangle Area
# ----------------------------------------------------------------------------------
def areaRec():
if s1 == 4:
print "You have chosen to calculate the area of a rectangle."
line()
print "Formula--is--Length*Width"
line()
length = input("What is the length of the rectangle")
width = input("What is the width of the rectangle.")
rect = length*width
sleep(1)
print "The answer is..."
print rect
help1 = input("If you would like to know how I came up with this answer. Type 911.")
if help1 == 911:
print "I took the length of the rectangle...", length
print "then i took the width................", width
print "Then multiplied......................", rect
# ___________________________________________________________________________________________________
# Addition
#________________________________________________________________________________________________________
def add():
if huh == 2:
print "OK, Addition is easy"
line()
print "First, lets go through what i need you to do"
Xa = input("What is X going to be?")
Ya = input("What do you want Y to be")
xyadd = Xa+Ya
line()
print "The answer to your addition problem is..."
print xyadd
#_________________________________________________________________________________________
# Subtraction
# _________________________________________________________________________________
def sub():
if huh == 3:
line()
print "OK, Subtraction is easy"
line()
print "First, lets go through what i need you to do"
Xs = input("What is X going to be?")
Ys = input("What do you want Y to be")
xysub = Xs - Ys
line()
print "The answer to your subtraction problem is..."
print xysub
help1 = input("If you would like to know how I came up with this answer. Type 911.")
if help1 == 911:
print "I first took X..................", Xs
print "then i took Y and subtracted it.", Ys
print " to get.........................", xysub
#____________________________________________________________________________
# Menu of Perimeter
#_____________________________________________________________________________
def menuPer():
if huh == 4:
print "________________________________"
print "What do you wish to calculate the perimeter of?"
line()
print "Circle_1"
print "Triangle_2"
print "Square_3"
print "Rectangle_4"
print "Anything_5"
twoline()
print "________________________________"
#----------------------------------------------------------------------------------
#Circle Perimeter
#---------------------------------------------------------------------------------
def perCir():
if s4 == 1:
# Formula is 2*Pi*R
print "You have chosen to calculate the circumference of a circle."
line()
print "Formula--is--2*Pi*R"
line()
rpc = input("What is the radius of the circle")
sumpi2 = 2*pi
perC = sumpi2*rpc
line()
sleep(1)
print "The answer is..."
print perC
line()
help1 = input("If you would like to know how I came up with this answer. Type 911.")
if help1 == 911:
print "I took 2..................................................2"
print "Then multiplied it by pi...............................", pi
print "Came out with the sum of...............................", sumpi2
print "Then took the sum of that and multiplied by the radius.", perC
#---------------------------------------------------------------------------------------
#Triangle, square, rectangle, anything Perimeter
#--------------------------------------------------------------------------------------
def perAny():
if s4 == 2 or 3 or 4 or 5:
print "If some of the questions do not apply, please press 0."
a = input("What is the measurement of side A")
b = input("What is the measurement of side B")
c = input("What is the measurement of side C")
d = input("What is the measurement of side D")
e = input("What is the measurement of side E")
if a or b or c or d or e == 0:
pass
sumperA = a + b + c + d + e
print sumperA
help1 = input("If you would like to know how I came up with this answer. Type 911.")
if help1 == 911:
print "I took the measure of side a which was", a
print "I took the measure of side b which was", b
print "I took the measure of side c which was", c
print "I took the measure of side d which was", d
print "I took the measure of side e whish was", e
print "Then added all together...", sumperA
#________________________________________________________________________________
#Division
# _____________________________________________________________________________
def menuDiv():
if huh == 5:
line()
print "OK, Division is easy"
line()
print "First, lets go through what i need you to do"
Xd = input("What is X going to be?")
Yd = input("What do you want Y to be")
xydiv = Xd/Yd
sleep(1)
line()
print "The answer to your division problem is..."
print xydiv
help1 = input("If you would like to know how I came up with this answer. Type 911.")
if help1 == 911:
print "I took X, which was", Xd
print "then divided it by your Y", Yd
#________________________________________________________________________
#Multiplication
#______________________________________________________________________
def menuMult():
if huh == 6:
line()
print "OK, Multiplication is easy"
line()
print "First, lets go through what i need you to do"
Xm = input("What is X going to be?")
Ym = input("What do you want Y to be")
xymul = Xm*Ym
sleep(1)
line()
print "The answer to your division problem is..."
print xymul
help1 = input("If you would like to know how I came up with this answer. Type 911.")
if help1 == 911:
print "I took X, which was.............", Xm
print "then multiplied it by your Y....", Ym
print "To come out with................", xymul
###############################################################################
#This is the format that everything should run in!#
print "################################################################"
print "# #"
print "# This is a Calculater! Use at your own risk! #"
print "# If you need help running the program, please contact... #"
print "# Jamahrae Jackson :-) #"
print "# #"
print "# XpoJayco.inc #"
print "# #"
print "# Copyright 2005 #"
print "################################################################"
twoline()
print "XpoJayco Calculater"
twoline()
def grand():
firstMenu()
huh = input("So, your selection is?")
if huh == 1:
areaMenu()
s1 = input("Your choice, please?")
if s1 == 1:
raw_input("press Return>")
areaCir()
if s1 == 2:
raw_input("press Return>")
areaTri()
if s1 == 3:
raw_input("press Return>")
areaSqu()
if s1 == 4:
raw_input("press Return>")
areaRec()
if huh == 2:
raw_input("press Return>")
add()
if huh == 3:
sub()
if huh == 4:
menuPer()
s4 = input("Your selection, please?")
if s4 == 1:
raw_input("press Return>")
perCir()
if s4 == 2 or 3 or 4 or 5:
raw_input("press Return>")
perAny()
if huh == 5:
raw_input("press Return>")
menuDiv()
if huh == 6:
raw_input("press Return>")
menuMult()
return grand()
##############################################
# ORDER #
firstMenu()
huh = input("So, your selection is?-----")
if huh == 1:
areaMenu()
s1 = input("Your choice, please?-----")
if s1 == 1:
raw_input("press Return>")
areaCir()
raw_input("Press Return>>>")
if s1 == 2:
raw_input("press Return>")
areaTri()
raw_input("Press Return>>>")
if s1 == 3:
raw_input("press Return>")
areaSqu()
raw_input("Press Return>>>")
if s1 == 4:
raw_input("press Return>")
areaRec()
raw_input("Press Return>>>")
if huh == 2:
raw_input("press Return>")
add()
if huh == 3:
raw_input("Press Return>>>")
sub()
raw_input("Press Return>>>")
if huh == 4:
menuPer()
s4 = input("Your selection, please?-----")
if s4 == 1:
perCir()
raw_input("press Return>")
if s4 == 2 or 3 or 4 or 5:
perAny()
raw_input("press Return>")
if huh == 5:
raw_input("press Return>")
menuDiv()
raw_input("Press Return>>>")
if huh == 6:
raw_input("press Return>")
menuMult()
raw_input("Press Return>>>")
def again2():
contin = raw_input("Want to try another, if so, press return.")
if contin == contin:
main()
main()
main()
main()
main()
else:
legal()
again2()
Last edited by JayIBM; 12-13-2005 at 08:43 PM. |
|
|
|
![]() |
| Thread Tools | |
|
|