Question

Write a Visual Basic program to find the sum of five ages provided by the user....

Write a Visual Basic program to find the sum of five ages provided by the user. Use a Do While loop to prompt and read in a value for each age from the user. After the loop, display the calculated value for the sum on the monitor.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

public class compiler
shared function Main as integer
' Your code here!
Dim age As Integer
Dim total As Integer
Dim i As Integer
total = 0
i=0
Do While i<5
Console.WriteLine("Enter age "& i+1 & ":") 'Reading inout from user
age = Console.ReadLine()
total = total + age 'adding to the total age
i = i+1
Loop
Console.WriteLine ("Sum of ages is "& total) 'Printing the total age
return 0
End function
end class

Input:

2
34
5
6
7

Output:

Enter age 1:
Enter age 2:
Enter age 3:
Enter age 4:
Enter age 5:
Sum of ages is 54
Add a comment
Know the answer?
Add Answer to:
Write a Visual Basic program to find the sum of five ages provided by the user....
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT