Jump to content


 


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.


Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Photo

Program - Have No Idea!


  • This topic is locked This topic is locked
12 replies to this topic

#1 susie86

susie86

  • Members
  • 21 posts
  • OFFLINE
  •  
  • Local time:08:29 AM

Posted 10 October 2006 - 06:51 AM

Hey guys!
I have to write this VB program...I just need a bit of guidance...I honestly have absolutely no clue what to do...please help...just to kinda start me off...(or a bit more! lol) please please help...I'll be ever so grateful and make a donation to this awesome website!!
If anyone is willing to chat about it online that would be great...(i think its too complicated to post on here)...my email/msn address is XXXXXXXXXXXXXXX@hotmail.com

Thank you so much!! Any help would be so much appreciated!! xxx


(Moderator edit: E-mail address deleted to protect member privacy and to avoid its harvesting by spambots. Members should never post either IM names or E-mail addresses in public forums. jgweed)

Edited by jgweed, 10 October 2006 - 07:52 AM.


BC AdBot (Login to Remove)

 


m

#2 ussr1943

ussr1943

  • Members
  • 490 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:USA
  • Local time:09:29 AM

Posted 10 October 2006 - 03:37 PM

nothings ever too hard. give us a post maybe we can help.
good luck
"Ideas are far more powerful than guns."
"The only truly secure system is one that is powered off, cast in a block of concrete and sealed in a lead-lined room with armed guards -- and even then I have my doubts." --Eugene H. Spafford
"One man's terrorist is another's freedom fighter"

#3 susie86

susie86
  • Topic Starter

  • Members
  • 21 posts
  • OFFLINE
  •  
  • Local time:08:29 AM

Posted 10 October 2006 - 11:16 PM

Objective
Titanic Tanks Pty Ltd has employed you in their Receptacle Design Division to develop their range of water tanks. One particularly popular product in their range is tanks that are filled with water through a pipe controlled by a valve. At the same time the water drains out of the tank through another pipe. In this way the tank acts as a reservoir. The rate at which water flows through the valve and into the tank is also controlled by a sensor fitted to the tank. As the tank fills, the sensor reading is used to adjust the flow appropriately. The following diagram illustrates the general design.




When designing the tanks it is important to determine what height the water level will reach for a given maximum rate of flow of water through the control valve. In this assignment, you will write a Visual Basic program to assist in the design of the tank. The following description will explain how this problem is to be modelled in your program.

The rate of change of the height of the water in the tank is given by the equation

dx/dt = -α.√x + βu

(1)

where x represents the height of the water in metres, u represents the rate at which the water flows through the valve and fills the tank in metres per second and α and β are tank specific constants. For the purposes of this assignment, we will take α = β = 0.95.

As the tank fills and empties, the valve is adjusted according to the sensor reading. This affects the rate at which water flows through the valve and fills the tank and is represented by the variable u in the equation (1). This value can be determined as follows:

u = γ(1 - x/h )

(2)

where γ represents the maximum rate of flow of water into the tank in metres per second. In other words, when the tank is empty (x = 0) the rate of flow of the water is at its maximum possible (u = γ) while when the tank is full (x = h) the valve is shut (u = 0).

In this assignment, one of the main tasks is to determine the steady-state height of water in the tank (x) for a given maximum rate of flow of water (γ) into the tank. This can be determined by firstly substituting equation (2) into equation (1) and solving the following equation for x to determine the maxima:

dx = -α.√x + β&gamma(1 - x/h ) = 0


This is what the initial output should look like:


Enter option (change, flow, height or quit): change

Option not implemented

Enter option (change, flow, height or quit): flow

Option not implemented

Enter option (change, flow, height or quit): height

Option not implemented

Enter option (change, flow, height or quit): chnage

Invalid option

Enter option (change, flow, height or quit): quit

Bye!




When the user enters the flow option, prompt the user for the height of the tank (h), height of the water (x) and the maximum water flow rate (γ), then output the calculated flow rate (u) using equation (2). Furthermore, if no solution is possible output No solution. Note, your program should produce exactly the same output as the examples below in order to pass the automarking.

The following output shows what is expected. Note that all numeric output should be correct to two decimal places.

Enter option (change, flow, height or quit): flow

Enter height of tank (m): 0.5
Enter height of water (m): 0.3
Enter maximum water flow rate (m/s): 0.2
Flow rate = 0.08m/s

Enter option (change, flow, height or quit): flow

Enter height of tank (m): 0.5
Enter height of water (m): 0.8
Enter maximum water flow rate (m/s): 0.2
No solution

Enter option (change, flow, height or quit): quit

Bye!




When the user enters the change option, prompt the user for the height of the tank (h), height of the water (x) and the maximum water flow rate (γ), then output the calculated rate of change of the water level (dx/dt) using equation (1). If no solution is possible output No solution.

The following output presents an example.

Enter option (change, flow, height or quit): change

Enter height of tank (m): 0.5
Enter height of water (m): 0.3
Enter maximum water flow rate (m/s): 0.2
Rate of change in height = -0.44m/s

Enter option (change, flow, height or quit): change

Enter height of tank (m): 0.5
Enter height of water (m): 0.8
Enter maximum water flow rate (m/s): 0.2
No solution

Enter option (change, flow, height or quit): quit

Bye!





Input
The input values for the height of the tank, the height of the water and the maximum water flow rate should be of data type Double.

Output
The output of numeric values should be correct to two decimal places throughout your program.

Stage 4: Determining the Steady-State Height of the Water
In this stage of the assignment you are to determine the height of water in the tank (x) given the height of the tank (h) and the maximum possible rate of flow of water through the valve (γ) using the Bisection Method described above. This calculation is to be performed when the use enters the height option. If no solution is possible output No solution.

The following output shows what is expected.

Enter option (change, flow, height or quit): height

Enter height of tank (m): 1
Enter maximum water flow rate (m/s): 1
Height of water = 0.38m

Enter option (change, flow, height or quit): height

Enter height of tank (m): 0.3
Enter maximum water flow rate (m/s): 100
Height of water = 0.30m

Enter option (change, flow, height or quit): quit

Bye!




This is only the beginning of the assignment...hopefully if i can just get started i should be able to keep going...thank you so much for your help!! I'll owe you guys big time if you can help me out! xxx

#4 groovicus

groovicus

  • Security Colleague
  • 9,963 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Centerville, SD
  • Local time:07:29 AM

Posted 11 October 2006 - 07:50 AM

Ok, you'll probably hate this, but we don't do homework. (unless you want to do mine :thumbsup:)

What we can do is look at what existing code you have, and offer guidance on where to go next. Being as how you have no clue how to get started, us giving you sample code to copy menas you only learn to copy. You will not learn anything about tte actual structure of a program (which is where your knowledge seems to be lacking).

Show us what you have already. :flowers:

#5 susie86

susie86
  • Topic Starter

  • Members
  • 21 posts
  • OFFLINE
  •  
  • Local time:08:29 AM

Posted 11 October 2006 - 07:58 AM

aww...somehow I knew that might be the answer i was going to get! lol :thumbsup:
but thats understandable..any help is better than none..and you're right..i won't learn anything..
Unfortunately i don't have VB at home (its too expensive to buy for just a few weeks work - for me anyways, and the express version didnt work because i needed Windows XP SP2 and for some reason i couldnt get it)...anyways..this is what I have for stage 2...I modified it a bit but am yet to test it on the computers at school...thanks again!! xx

Dim Z$ as string

RePrompt:
Console.WriteLine ("Enter option(change, flow, height or quit):")

Z$ = Console.ReadLine

Select case Z$

case "change": goto DoChange

case "flow": goto DoFlow

case "height": goto DoHeight

case "quit": Console.WriteLine ("Bye!")
End ' this cause the program to end

case else: Console.WriteLine ("Invalid option")
goto RePrompt

End Select

DoChange:
Console.WriteLine ("Option not implemented")
goto RePrompt

DoFlow:
Console.WriteLine ("Option not implemented")
goto RePrompt

DoHeight:
Console.WriteLine ("Option not implemented")
goto RePrompt

#6 susie86

susie86
  • Topic Starter

  • Members
  • 21 posts
  • OFFLINE
  •  
  • Local time:08:29 AM

Posted 11 October 2006 - 07:32 PM

Hi,
me again...i made some adjustments to my existing code...still have to make sure it runs properly on the version of VB we are using at school...any help? Thanks again!! :thumbsup:



Sub Main()

Dim Z$ as string

RePrompt:
Console.WriteLine ("Enter option(change, flow, height or quit):")

Z$ = Console.ReadLine

Select case Z$

case "change": DoChange

case "flow": DoFlow

case "height": DoHeight

case "quit": Console.WriteLine ("Bye!")
End ' this cause the program to end

case else: Console.WriteLine ("Invalid option")

End Select

goto RePrompt

End Sub


'-------------------------------------------------------------------------------


Sub DoChange()

Console.WriteLine ("Enter height of tank (m):")
Z$ = Console.ReadLine
h = val(Z$)
Console.WriteLine ("Enter height of water (m):")
Z$ = Console.ReadLine
x = val(Z$)
Console.WriteLine ("Enter maximum water flow rate (m/s):")
Z$ = Console.ReadLine
y = val(Z$)

'Check to make sure user has entered reasonable values
If x>h or x<0 or h<0 or y<0 then
Console.WriteLine ("No solution")
goto RePrompt
EndIf

' the formula here
u = y * (1 - (x / h ) )

Console.WriteLine ("Rate of change in height = {0} m/s", u)

End Sub


'-------------------------------------------------------------------------------


Sub DoFlow()

Console.WriteLine ("Enter height of tank (m):")
Z$ = Console.ReadLine
h = val(Z$)
Console.WriteLine ("Enter height of water (m):")
Z$ = Console.ReadLine
x = val(Z$)
Console.WriteLine ("Enter maximum water flow rate (m/s):")
Z$ = Console.ReadLine
y = val(Z$)

'Check to make sure user has entered reasonable values
If x>h or x<0 or h<0 or y<0 then
Console.WriteLine ("No solution")
goto RePrompt
EndIf

' the formula here
u = y * (1 - (x / h ) )

Console.WriteLine ("Flow rate = {0} m/s", u)

End Sub


'-------------------------------------------------------------------------------


Sub DoHeight()

Console.WriteLine ("Option not implemented")

End Sub

#7 groovicus

groovicus

  • Security Colleague
  • 9,963 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Centerville, SD
  • Local time:07:29 AM

Posted 12 October 2006 - 05:27 PM

I am not very VBish, but in general, programming problems are programming problems, irrespective of the language they are implemented in. Are you having any problems at the moment?

#8 susie86

susie86
  • Topic Starter

  • Members
  • 21 posts
  • OFFLINE
  •  
  • Local time:08:29 AM

Posted 13 October 2006 - 04:43 PM

Hi,
well....my DoFlow seems to be working ok...its my Change and Height values...i seem to always get zero...any suggestions?

#9 projectfocus

projectfocus

  • Members
  • 474 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Brighton
  • Local time:02:29 PM

Posted 20 November 2006 - 11:56 AM

Why are both functions the same code. Neather seem to be dependant on the users first case statement. Give some examples of the values you are running through it.
Posted Image

#10 projectfocus

projectfocus

  • Members
  • 474 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Brighton
  • Local time:02:29 PM

Posted 20 November 2006 - 12:03 PM

Also I have noticed that you have not assinged a variable type to the U X and Y. This will mean that it will not handle the values corectly as it does not support decimal numbers and will round the value to the nearest point.


u = 2 * (1 - (2/1)) Example figures but look at the end values rounded

u = 2 * 1-2
u = 2 * -1
u = -2

Considering normal Integers that it will be assigned by default dont accept minus values that is why it is always 0.
Posted Image

#11 projectfocus

projectfocus

  • Members
  • 474 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Brighton
  • Local time:02:29 PM

Posted 21 November 2006 - 11:48 AM

Try assigning the variable as a Double in the sub.

Dim u,h,x,y as double


Although I am yet to see what the $ does after the variable declaration.
Posted Image

#12 Keithuk

Keithuk

  • Members
  • 951 posts
  • OFFLINE
  •  
  • Gender:Male
  • Local time:01:29 PM

Posted 28 January 2007 - 10:14 AM

Thats not Visual Basic thats VB.Net.

Join a VB.Net forum. :thumbsup:

Try assigning the variable as a Double in the sub.

Dim u,h,x,y as double

You don't declare variables like that, only y will be a Double the rest will be Variants.
Dim u As Double,h As Double,x As Double,y As Double

Edited by Keithuk, 28 January 2007 - 10:18 AM.

Keith

Windows ME (spare computer)
Windows XP 2002 Professional SP3 (desktop computer)
Windows 7 Professional SP1 32bit (laptop computer)

Windows 8 64bit spare drive for laptop computer


#13 groovicus

groovicus

  • Security Colleague
  • 9,963 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Centerville, SD
  • Local time:07:29 AM

Posted 28 January 2007 - 10:42 AM

Join a VB.Net forum.


We really don't like to hear comments like that. Either offer help, or don't. We have many talented people here that are willing to help no matter the scope of the question.

Since the original OP has not returned, I am closing this topic.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users