Jump to content

Visual Basic Assighment Help. (Translating pseudocode to visual basic)

- - - - -

  • Please log in to reply
1 reply to this topic

#1
Adolf B

Adolf B

    Newbie

  • Members
  • Pip
  • 2 posts
okay so i am doing a basic programing logic class. and i have an assighment and i need to translate the pseudocode to visual basic 08 as a consol application. the problem is i need some serious help because i never used visual basic for the exception of some examples given in class.

- so this is the question.

-rick hammer is a carpenter who wants an application to compute the price of any desk a customer orders, based on the following: desk length and width in inches, type of wood, and number of drawers. The price computes as follows.
-The minimum charge for all desks is 200 $
-If the surface (length*width) is over 750 square inches add 50 $ .
-If the wood is mahogany, add 150 $; for oak, add 125 $. No charge is added for pine.
-For every drawer in the desk, there is an additional 30 $ charge.
The Question.
- Design a pseudocode for the program.
a) A program that accepts data for an order number, customer name, length and width of the desk ordered, type of wood, and number of drawers. Display all the entered data and final price for the desk.

this is my pseudo-code

Start

Declarations

String Customer_Name

Num Order_Number

Num Length,_Width

String Type_of_Wood

Num Price=200

Num _of _Drawers

Num Total_Cost

HouseKeeping ()

Input Customer_Name

Output Please enter Customer_Name

Input Order_Num

Output Please enter Order_Num

Input Lenghth,_Width

Output Please enter Lenghth,_Width

Input Type_Of_Wood

Output Please enter Type_of_Wood

Input Num_of_Drawers

Output Please enter Num_of_Drawers

Input Price=200

Output Price=200

Num Total_Cost

Return

Detail ()

If Lenghth,_Width > 750 then

Price=200+50

If Type_of_Wood = “Mahogany” Then

Price=200+150

If Type_of_Wood=”Oak” Then

Price=200+125

If Type_of_Wood= Pine Then

Price=200+0

If Num_of_Drawers < 1 Then

Price=200+30

Output: Order_Num, Customer_Name, and Total_Cost

Return

Return
End of Job ()


Option Explicit On

‘Output: “Thanks for using my program”

Return






okay i tried and this is what i think it can be for visual basic.




'FinalPriceOfDesk.Vb - This program accepts data for an order number, customer name, length and width of the desk ordered, type of wood, and number of drawers. Display all the entered data and final price for the desk.'
Option Explicit On
Option Strict On
Module FinalPriceOfDesk

Sub main ()

'Work done in the Declarations Module

String Customer_Nam

Num Order_Number

Num Length,_Width

String Type_of_Wood

Num Price=200 as Integer

Num _of _Drawers

Num Total_Cost

'Work done in the HouseKeeping Module

Dim Input Customer_Name

Output Please enter Customer_Name

Dim Input Order_Num

Output Please enter Order_Num

Dim Input Lenghth,_Width

Output Please enter Lenghth,_Width

Dim Input Type_Of_Wood

Output Please enter Type_of_Wood

Dim Input Num_of_Drawers

Output Please enter Num_of_Drawers

Dim Input Price=200

Output Price=200

Dim Num Total_Cost

'Work done in the Detail Module

If Lenghth,_Width > 750 then

Dim Price=200+50

If Type_of_Wood = “Mahogany” Then

Dim Price=200+150

If Type_of_Wood=”Oak” Then

Dim Price=200+125

If Type_of_Wood= Pine Then

Dim Price=200+0

If Num_of_Drawers < 1 Then

Dim Price=200+30
End If

Work on EndOfJob Module

System.Console.WriteLine("Customer_Name: " & Order_Number: " & Total_Cost)
System.Console.WriteLine("Thank You For Using My Program)

End Sub

End Module

I know I am probaly wrong please help...

#2
Simonxz

Simonxz

    Learning Programmer

  • Members
  • PipPipPip
  • 42 posts
Dim means Declared In Memory, in your Ifs statements, you should only use Price (not Dim Price) because it would declare it every time (it won't, you'll get a compiler error). A related problem in your declarations, you should use Dim there.

Have you tried compiling your code? If you don't have Visual Studio you can get the express version for free on Microsoft's website.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users