PHP week PHP week
This week up to 80% off on PHP courses. More info

Exercises for Visual Basic .NET lessons 1-3

The following exercises will help you put your knowledge of Visual Basic .NET to the test. Based off of what you've learned from previous lessons. Try to solve them on your own, but know that you could always download the working solutions under the article. Nonetheless, beware that when you view the solution without solving the exercise, you won't learn anything :)

If you find yourself stuck at some point, you should always try going back to check previous tutorials first and figure the problem out by yourself.

Easy exercise

Create an application which will ask for a username and then for his/her ability. Then the program will print "name is ability", see image below.

The application screen sample:

Console application
Hi, what is your name?
Bill Gates
What are you like?
ultraepic rich
Bill Gates is ultraepic rich

Intermediate exercise

Create an application which will ask for an integer and prints its second power (x squared).

The application screen sample:

Console application
Enter a number, and I'll square it:
64
Result: 4096

Advanced exercise

Create an application that will ask for a circle's radius. Then print its circumference and its area.

The application screen sample:

Console application
Enter the circle's radius (cm):
12.1
The circle's circumference based on the given radius is: 75.98801 cm
Area of the circle is: 459.7274 cm^2

 

Download

Downloaded 32x (109.97 kB)
Application includes source codes in language VB.NET

 

 

Article has been written for you by David Capka
Avatar
Do you like this article?
1 votes
The author is a programmer, who likes web technologies and being the lead/chief article writer at ICT.social. He shares his knowledge with the community and is always looking to improve. He believes that anyone can do what they set their mind to.
Unicorn College The author learned IT at the Unicorn College - a prestigious college providing education on IT and economics.
Previous article
Variables and type system in VB.NET
All articles in this section
Visual Basic (VB.NET) basic constructs
Thumbnail
Next article
More on the VB.NET type system: Data types
Activities (2)

 

 

Comments

Avatar
wasim
Member
Avatar
wasim:23. June 20:37

I don't know it's the right way or not, can you please have a look at the first exercise.

Console.Write­Line("Hi, what is your name? ")
Dim input, output As String
input = Console.ReadLine()

Console.Write­Line("What are you like? ")
output = Console.ReadLine()
Console.Write­Line(input & " is " & output)

Console.ReadKey()
Thank you

 
Reply 23. June 20:37
Avatar
wasim
Member
Avatar
wasim:23. June 20:47

Intermediate exercise code
Console.Write­Line("Enter a number, and I'll square it: ")
Dim sqrt As Double
sqrt = Console.ReadLine()

Console.Write­Line("Result: " & sqrt ^ 2)
Console.ReadKey()
Please tell me doing right :-) Thank you

 
Reply 23. June 20:47
Avatar
wasim
Member
Avatar
wasim:24. June 0:00

The last one took me so long to figure it out, I am pretty sure it's the wrong code.

Console.Write­Line("Enter the circle's radius (cm):")
Dim c, r, pi As Double
pi = 3.142
c = 2 * 3.142 * r
r = Console.ReadLine()

Console.Write­Line("The circle's circumference based on the given radius is: " & 2 * 3.142 * r & " cm")
Console.Write­Line("Area of the circle is: " & r * r * pi & "cm2")
Console.ReadKey()
Thank you

Edited 24. June 0:02
 
Reply 24. June 0:00
Avatar
David Capka
ICT.social team
Avatar
Replies to wasim
David Capka:24. June 5:23

Hi wasim,
all the 3 codes you posted are ok. The last result is a bit different than ours since you chose your pi to be 3.142 but it's not specified in the task description so you passed. Good job :)

Reply  +1 24. June 5:23
You can walk through a storm and feel the wind but you know you are not the wind.
Avatar
wasim
Member
Avatar
Replies to David Capka
wasim:25. June 18:14

Thank you, David.

 
Reply 25. June 18:14
To maintain the quality of discussion, we only allow registered members to comment. Sign in. If you're new, Sign up, it's free.

5 messages from 5 displayed.