Question

visual studio VB.Net write a vb.net program to create an array of 15 structures, each structure...

visual studio
VB.Net


write a vb.net program to create an array of 15 structures, each structure contains the following fields: user name, number of
posts, then write a sub to read from the keyboard values into the structures fields and write a function to find and return the
average of number of posts for all users and write a sub to print the user name that has zero number of posts.[ number of posts could
be from 0 or more]

Homework Answers

Answer #1

Solution:

Code:

Copyable code:

Module VBModule
'Structure definition
Structure Posts
Public userName As String
Public noPosts As Integer
End Structure
  
'Variable declaration
Dim arrOfPosts(15) As Posts
Dim i As Integer

'Sub for getting input
Sub input()
'Loop
For i=0 to 15
Console.WriteLine("Enter the user name"&i)
arrOfPosts(i).userName=Console.ReadLine()
Console.WriteLine("Enter Number of posts"&i)
arrOfPosts(i).noPosts=Console.Read()
Next i
End Sub
  
'Function to Find average
Function average() as double
Dim sum,ave as Double
sum=0
'Loop
For i=0 to 15
sum=sum+arrOfPosts(i).noPosts
Next i
ave=sum/15
average=ave
End Function
  
'Sub to find zero number of posts
Sub zeroPosts()
'Loop
For i=0 to 15
'Condition
If(arrOfPosts(i).noPosts=0)Then
Console.WriteLine("UserName with zero posts is:"&arrOfPosts(i).userName)
End If
Next i
End Sub
  
'main Sub
Sub Main()
'Call the procedures and functions
input()
Console.WriteLine("Average:"&average())
zeroPosts()
End Sub
  
End Module

Know the answer?
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
Similar Questions
In c++ Write a program that creates a dynamically allocated array to store students’ grades. The...
In c++ Write a program that creates a dynamically allocated array to store students’ grades. The user should be able to decide the size of the array during run time. Write code to fill this array from the keyboard and then print out the values of your array,
Write a program in c++ to Convert an array of inches to an array of centimeters....
Write a program in c++ to Convert an array of inches to an array of centimeters. The program should contain a function called inchesTOcm with three parameters (inches array that contains the values in inches, cm array to save the result in, and an integer variable that defines the length of the array). In the main function: 1. Define an array (inches) of length 3. 2. Initialize the array by asking the user to input the values of its elements....
Using C++ 1. Create a program that asks the user to create 5 triangles, asking for...
Using C++ 1. Create a program that asks the user to create 5 triangles, asking for 5 bases and 5 heights (you can use an array), have a function to print the triangle bases, heights, and areas 2. Create a structure for the Triangle that holds the base and height of the triangles. Ask the user for 5 triangles, and print them. 3. Create an array of 5 structures - ask the user for 5 triangles, and then print the...
Create a Visual Studio console project named exercise071 containing a main() program that in a single...
Create a Visual Studio console project named exercise071 containing a main() program that in a single statement declares an int array named primes and initializes the 5 entries to the first prime numbers. The primes start at 2 since 1 is not a prime number. Display the array on a single console line beginning with "Primes: " and a blank separating the numbers. A loop is not required.
Please Write code in visual studio Roman Numeral Converter Write a program that asks the user...
Please Write code in visual studio Roman Numeral Converter Write a program that asks the user to enter a number within the range of 1 through 10. Use a switch statement to display the Roman numeral version of that number. Input Validation: Decide how the program should handle an input that is less then 1 or greater than 10.
Write a C program that prompts the user to enter a line of text on the...
Write a C program that prompts the user to enter a line of text on the keyboard then echoes the entire line. The program should continue echoing each line until the user responds to the prompt by not entering any text and hitting the return key. Your program should have two functions, writeStr and readLn, in addition to the main function. The text string itself should be stored in a char array in main. Both functions should operate on NUL-terminated...
In C++ Employee Class Write a class named Employee (see definition below), create an array of...
In C++ Employee Class Write a class named Employee (see definition below), create an array of Employee objects, and process the array using three functions. In main create an array of 100 Employee objects using the default constructor. The program will repeatedly execute four menu items selected by the user, in main: 1) in a function, store in the array of Employee objects the user-entered data shown below (but program to allow an unknown number of objects to be stored,...
Write a Java program to randomly create an array of 50 double values. Prompt the user...
Write a Java program to randomly create an array of 50 double values. Prompt the user to enter an index and prints the corresponding array value. Include exception handling that prevents the program from terminating if an out of range index is entered by the user. (HINT: The exception thrown will be ArrayIndexOutOfBounds)
IN JAVA 1. Write up a small program that accepts two integers from the user. Print...
IN JAVA 1. Write up a small program that accepts two integers from the user. Print which of the two values is bigger. If they are the same, print that they are the same. 2. Write a method that accepts three doubles. Calculate and return the average of the three passed double values. 3. Write up a method that accepts a score between 0-10. Print out a message according to the following table. You ay personally decide the boundaries. i.e.,...
Program C++ (use visual studio) Q1. What default copy constructor does the compiler insert in the...
Program C++ (use visual studio) Q1. What default copy constructor does the compiler insert in the following class? class Student { string name; string id; double grade; }; =========================== Q2 .What is the factor transfer method used when the f() function is called from? void f(int n[]); int main() { int m[3]= {1, 2, 3}; f(m); } ================================== Q3. Write a program that produces a bigger() with a prototype as shown below and outputs a large value by inputting two...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT