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...
C++ Visual Studio 2019 Write a C++ console application that accepts up to 5 numbers from...
C++ Visual Studio 2019 Write a C++ console application that accepts up to 5 numbers from the user. Display all numbers, the highest, the lowest, and the average of the numbers. Ask the user if they want to continue entering another set of numbers. 1) Use proper naming conventions for your variables and functions. 2) Tell the user what the program is all about. Do NOT start the program with “Enter a number”!! 3) Create an array to store 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.
Movie Structure File Write a program that will read in a CSV file with information regarding...
Movie Structure File Write a program that will read in a CSV file with information regarding movies. The file will contain a movie name, MPAA coding (G, PG, PG-13, R), number of minutes, and ratings (1-10) from the three top critics. Your program will read in the data into an array of structures (No more than 20 movies) and send the array to a function that will produce a professional report file (MovieReport.txt) which includes all of the information, an...
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)
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT