473,405 Members | 2,344 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Array help. IfThen help. I am new to programming

1
I have an assignment for school and I am new to programming. For the assignment I need to make a survey with at least 4 choices that uses 2 arrays. It must be done in a console application. How do I make it loop and count/store the responses until the user enters "N" at strAnswer=Console.readline? Where/what loop would I use?

Expand|Select|Wrap|Line Numbers
  1. Module Module1
  2.  
  3.    Sub Main()
  4.       Dim strAnswer As String
  5.       Console.WriteLine("Do you want to answer survey")
  6.       strAnswer = Console.ReadLine()
  7.       While Not strAnswer.ToUpper.StartsWith("N")
  8.          Dim resp(3) As Integer
  9.          Console.WriteLine("Pick a number between 1 and 4")
  10.          resp(0) = Console.ReadLine
  11.          'declare response frequency array
  12.          Dim frequency As Integer() = New Integer(4) {}
  13.          ' count frequencies
  14.          For answer As Integer = 0 To resp.GetUpperBound(0)
  15.             frequency(resp(answer)) += 1
  16.          Next
  17.          Console.WriteLine("Choices" & vbTab & "Frequency")
  18.          'display output
  19.          For rating As Integer = 1 To frequency.GetUpperBound(0)
  20.             Console.WriteLine(rating & vbTab & frequency(rating))
  21.          Next
  22.          Console.WriteLine("Do you want to answer survey")
  23.          strAnswer = Console.ReadLine()
  24.       End While
  25.    End Sub
  26. End Module
Feb 25 '08 #1
1 1814
debasisdas
8,127 Expert 4TB
Question moved to .net forum.
Feb 25 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: William | last post by:
I would appreciate your help on the following programming questions: 1. Given an array of length N containing integers between 1 and N, determine if it contains any duplicates. HINT: The...
6
by: n00dle | last post by:
hi, see if i want to copy the contents of a char arrary into a equally size struct, assuming that the structure has no holes, padding etc., i can use structure = *(t_structure *) array; but...
104
by: Leszek | last post by:
Hi. Is it possible in javascript to operate on an array without knowing how mamy elements it has? What i want to do is sending an array to a script, and this script should add all values from...
17
by: newgoat | last post by:
As far as I understand, in "int arr", the name of the integer array "arr" is equivalent to the pointer to the first element of the array. But is "arr" really a pointer, identical as "int *arr;" ?...
30
by: questions? | last post by:
say I have a structure which have an array inside. e.g. struct random_struct{ char name; int month; } if the array is not intialized by me, in a sense after I allocated a
6
by: Niyazi | last post by:
Hi all, What is fastest way removing duplicated value from string array using vb.net? Here is what currently I am doing but the the array contains over 16000 items. And it just do it in 10 or...
45
by: VK | last post by:
(see the post by ASM in the original thread; can be seen at <http://groups.google.com/group/comp.lang.javascript/browse_frm/thread/3716384d8bfa1b0b> as an option) As that is not in relevance to...
14
by: Shhnwz.a | last post by:
Hi, I am in confusion regarding jargons. When it is technically correct to say.. String or Character Array.in c. just give me your perspectives in this issue. Thanx in Advance.
5
by: benyboy | last post by:
hi, after hours of staring at my computer screen, and browsing through various internet forums i am totally stuck! I have created the following array which reads from an input file the following...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.