Jump to content

programing Question

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
3 replies to this topic

#1
geno53

geno53

    Newbie

  • Members
  • PipPip
  • 11 posts
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

#2
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
What do you have so far?

Note: we do not do homework for you, we help you do your homework.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#3
geno53

geno53

    Newbie

  • Members
  • PipPip
  • 11 posts
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

#4
sam_l

sam_l

    Learning Programmer

  • Members
  • PipPipPip
  • 52 posts
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.