develop a menu-driven program that inputs a number X, and at the user's option, finds and displays the area (A) of one of the following: A square with side X, A = X^2, After I run this program I get an output error what should this look like? What should this look like written in VB
programing Question
Started by geno53, Jan 15 2011 07:58 PM
3 replies to this topic
#1
Posted 15 January 2011 - 07:58 PM
|
|
|
#2
Posted 16 January 2011 - 06:35 AM
What do you have so far?
Note: we do not do homework for you, we help you do your homework.
Note: we do not do homework for you, we help you do your homework.
#3
Posted 21 January 2011 - 09:11 AM
I gave only part of this programming question but for any other person who might need a little help here is one way to do the problem.
Declare X As Float
Declare Choice As Integer
Call WelcomeMessage
Call InputData (X)
Call InputChoice(Choice)
Select Case Of Choice
Case: 1
Call Square(X)
Case: 2
Call Circle(X)
Case: 3
Call Triangle(X)
Default:
Write "Input not understood. Run the program again."
End Case
End Program
Subprogram WelcomeMessage
Write "This program computes areas for a square, circle, or a triangle"
Write "based on the users input."
End Subprogram
Subprogram InputData (Float X As Ref)
Write "Please input a value:"
Input X
End Subprogram
Subprogram InputChoice (Integer Choice As Ref)
Write "Enter 1 to compute the area of a square with side, X"
Write "Enter 2 to compute the area of a circle with radius, X"
Write "Enter 3 to compute the area of an equilateral triangle with side, X"
Input Choice
End Subprogram
Subprogram Square (Float X)
Declare A As Float
Set A = X^2
Write "The area of the square is:"
Write A
End Subprogram
Subprogram Circle (Float X)
Declare A As Float
Set A = 3.14 * X^2
Write "The area of the circle is:"
Write A
End Subprogram
Subprogram Triangle (Float X)
Declare A As Float
Set A = Sqrt (3/4) * X^2
Write "The area of the triangle is:"
Write A
End Subprogram
Declare X As Float
Declare Choice As Integer
Call WelcomeMessage
Call InputData (X)
Call InputChoice(Choice)
Select Case Of Choice
Case: 1
Call Square(X)
Case: 2
Call Circle(X)
Case: 3
Call Triangle(X)
Default:
Write "Input not understood. Run the program again."
End Case
End Program
Subprogram WelcomeMessage
Write "This program computes areas for a square, circle, or a triangle"
Write "based on the users input."
End Subprogram
Subprogram InputData (Float X As Ref)
Write "Please input a value:"
Input X
End Subprogram
Subprogram InputChoice (Integer Choice As Ref)
Write "Enter 1 to compute the area of a square with side, X"
Write "Enter 2 to compute the area of a circle with radius, X"
Write "Enter 3 to compute the area of an equilateral triangle with side, X"
Input Choice
End Subprogram
Subprogram Square (Float X)
Declare A As Float
Set A = X^2
Write "The area of the square is:"
Write A
End Subprogram
Subprogram Circle (Float X)
Declare A As Float
Set A = 3.14 * X^2
Write "The area of the circle is:"
Write A
End Subprogram
Subprogram Triangle (Float X)
Declare A As Float
Set A = Sqrt (3/4) * X^2
Write "The area of the triangle is:"
Write A
End Subprogram
#4
Posted 21 January 2011 - 12:26 PM
develop a menu-driven program that inputs a number X, and at the user's option, finds and displays the area (A) of one of the following: A square with side X, A = X^2, After I run this program I get an output error what should this look like? What should this look like written in VB
Menu-driven is overkill, but even if you wish to do so it should be a simple matter. When the user clicks on the "Input Side" menu item display an http://msdn.microsof...8w(VS.90).aspx. Validate input, preform the calculation and display using a MessageBox.
Menu-driven is overkill, but even if you wish to do so it should be a simple matter. When the user clicks on the "Input Side" menu item display an http://msdn.microsof...8w(VS.90).aspx. Validate input, preform the calculation and display using a MessageBox.


Sign In
Create Account


Back to top









