Ill guy needs help programming

mrapoc

New member
I've been off for 6 days with suspected meningitis but has luckily turned out to be a really strong flu virus variant (kinda scared me when I had a massive rash but it turned out to be non harmful). I've found out my event-driven programming course has been given homework to investigate on.

I would appreciate it if someone gave a bit of time just to write it (only needs to be simple like this is our fourth week doing it) plus to comment on each major part so I can understand whats going on ('insert comment)

I'm still not 100% so I'm goin to have to start looking at it from now even if i dont go back till later in the week.

Much appreciated (its visual basic express/studio that we use)

Week 4 Example Questions (using IFs and Loops)

You are expected to show these to your tutor at your next lesson. It is advisable that you have a go

at these questions, and try and work them out by yourself, as it will aid your learning of the subject.

If you don’t complete these in your lesson, complete them at home.

• Remember to add comments throughout your programs.

• Concentrate on the algorithms (the steps needed to solve the problem) - don't be overly

fussy about the interface.

• Be prepared to use pencil and paper to work out how a problem might be solved.

• Test your program thoroughly.

1. Write a program that will input 3 whole numbers from a user, and multiply them together.

Output the result to the console.

2. Write a program that will ask the user for their name and year of birth, and will then output

a suitable greeting message, telling the person their calculated age.

3. Add to the age program above, where different output is given depending on the users

calculated age. For example, if they are 17 or over, tell them they can drive, if they are 18 or

older also tell them they can drink and vote etc. But if they are less than 1 or older than 130

tell them they may be mistaken, and ask them to input their age again.

4. Write a program to print the numbers from 1 to 10 and their squares:

1 1

2 4

3 9

...

10 100

5. Write a program to print this triangle (don’t just use a set of print statements, program it!):

*

**

***

****

*****

******

*******

********

*********

**********

I'm going back to bed, will check soon...thanks
 
I've got some very similar programs to those from when I was at uni but im struggling to find them at the moment, i'll keep lookin though.
 
OK it works like this >> What Lang are u using -- if its VBASIC I wont be supplying you with the fully formatted Grammaticaly correct code

this nothing personal ... its just a dog -- and I use Linux and refuse to install Mono aka

'project sell out and allow proliferation of some poorly conceived M$ scumcode'

-- sh1t for c# they ripped off java (a smart move as every uni loves teaching Java ) [Stopped my self goin off in a rant]

If it is C# ill give u java code -- the keywords/syntax are identical ... classes are not-- so u will neeed to edit some junk

eg. Change System.Out.print ("foo"); to Console.Write("foo");

I have to go to class soon but i will help u when i get back
 
its vb lol

i use visual basic express at home and the studio at college (no difference apart from express is free)
 
name='Joe' said:
OK it works like this >> What Lang are u using -- if its VBASIC I wont be supplying you with the fully formatted Grammaticaly correct code

this nothing personal ... its just a dog -- and I use Linux and refuse to install Mono aka

'project sell out and allow proliferation of some poorly conceived M$ scumcode'

-- sh1t for c# they ripped off java (a smart move as every uni loves teaching Java ) [Stopped my self goin off in a rant]

If it is C# ill give u java code -- the keywords/syntax are identical ... classes are not-- so u will neeed to edit some junk

eg. Change System.Out.print ("foo"); to Console.Write("foo");

I have to go to class soon but i will help u when i get back

The way I used to help peoples in college tbh.

They`d have problems to sort out in Pascal, and as opposed to `doing it for them`, I`d give it to them in C so atleast they`d have to wrap their heads around it to make sure it worked as they wanted.
 
You really should do this yourself, or at least spend a while hacking around with it and trying to make it do even more.

Task 3 might not be exactly what is required, the wording isn't very specific as to the exact output.

I'm not a VB developer but this compiles and runs in my Visual Studio 2005.

Code:
' Your Homework in Visual Basic.

Module Homework

Sub Main()

' Task 1

Dim N1 As Integer

Dim N2 As Integer

Dim N3 As Integer

' Read 1st number

Console.Write("Enter #1: ")

N1 = Console.ReadLine()

' Read 2nd number

Console.Write("Enter #1: ")

N2 = Console.ReadLine()

' Read 3rd number

Console.Write("Enter #1: ")

N3 = Console.ReadLine()

' Multiply and output

Console.WriteLine(N1 * N2 * N3)

' Task 2

Dim Name As String

Dim Year As Integer

Dim Age As Integer

' Ask for name

Console.Write("Enter your name: ")

Name = Console.ReadLine()

' Ask for birth year

Do

Console.Write("What year were you born: ")

Year = Console.ReadLine()

' Calculate age in years

Age = Today().Year - Year

' Task 3

If (Age < 1 Or Age > 130) Then

Console.WriteLine("You must be mistaken, please try again")

Else

Exit Do

End If

Loop

' Task 2; Output greeting

Console.WriteLine("Hello " + Name + " you are " + CStr(Age) + " years old.")

' Task 3

' If 17 or older output can drive

If (Age >= 17) Then

Console.WriteLine("You can drive!")

End If

' If 18 or older output can drink and vote

If (Age >= 18) Then

Console.WriteLine("You can drink and vote!")

End If

' Task 4

Dim i As Integer

' Loop from 1 to 10 (inclusive)

For i = 1 To 10

' Output number and it's square

Console.WriteLine(CStr(i) + " " + CStr(i * i))

Next

' Task 5

Dim j As Integer

' Loop from 1 to 10 (inclusive)

For i = 1 To 10

' Loop from 1 to i (inclusive)

For j = 1 To i

' Output * without new line

Console.Write("*")

Next

' Output newline

Console.WriteLine()

Next

End Sub

End Module
 
Cheers, yea that wot i hope to do while ill, look through it so i know exactly what it does. Its just missed the lesson on loops due to illness and i dont feel up to working it out yet

ill give it a go
 
lol its jsut home based research. not important just to recap, and in my case learn cause i missed it lol
 
take it my assistance is not required then (slightly relieved ... I'Ve been coding all fricking day -- about 3 diff langs too)
 
name='mrapoc' said:
Its just missed the lesson on loops due to illness and i dont feel up to working it out yet

Also not having a go, but if you want to learn how to program, loops are quite a fundamental topic and you should probably learn about them.
 
Back
Top