Question

In: Computer Science

Write a program in Visual Basics that does the following: Read in 20 numbers, each of...

Write a program in Visual Basics that does the following:

Read in 20 numbers, each of which is between 10 and 100, inclusive. As each number is read, print it only if it is not a duplicate of a number already read. Provide for the “worst case” in which all 20 numbers are different. Use the smallest possible array to solve this problem.

Solutions

Expert Solution

Solution for the above program is provided below. If any doubt please comment below.

Visual Basic Code:

Module Module1

Sub Main()
' Declare variables
Dim value As Integer
Dim str As String
Dim i As Integer
Dim j As Integer
Dim flag As Boolean
' Declare array
Dim arr(20) As Integer
' Read 20 integers
For i = 0 To 19
' Read from input
str = Console.ReadLine()
' Convert to integer
value = CInt(str)
' Check value is between 10 and 100
If value < 10 Or value > 100 Then
i = i - 1
Else
flag = False
' Check the given value is alraedy read
For j = 0 To i
' If alraedy read set flag is true
If (value = arr(j)) Then
flag = True
End If
Next
' If not duplicate print the value
If flag = False Then
Console.WriteLine("Read Value " + CStr(i + 1) + ": " + str)
arr(i) = value
Else
i = i - 1
End If
End If
Next
Console.ReadLine()
End Sub
End Module

Output:


Related Solutions

Im working with visual basics for these problem. 1) Write a program that accepts five integers,...
Im working with visual basics for these problem. 1) Write a program that accepts five integers, and for each integer following the first, prints "GREATER" or "LESS" depending on whether or not the current integer is greater than the previous one. At the end, your application will let user know the largest and the smallest of the five numbers provided (BONUS): consider using the concepts of swapping the current and previous values as needed and don't use 5 variables.
(duplicate Elimination) use a one-dimensional array to slove the following program. read 20 numbers, each of...
(duplicate Elimination) use a one-dimensional array to slove the following program. read 20 numbers, each of which is between 10 and 100, inclusive. As each number is read, print if only if its not a duplicate of a number already read. Provide for the "worst case" in which all 20 numbers are different. Use the smallest possible array to slove this problem. sort the array in ascending order and print the elements of the sorted array. This much be done...
Using visual studio in MASM x86, Write a program to add the following word size numbers:...
Using visual studio in MASM x86, Write a program to add the following word size numbers: 15F2, 9E89, 8342, 99FF, 7130 using adc instruction and a loop. The result must be in DX, AX. Show the result in debug window.
write a c++ program that prompts a user to enter 10 numbers. this program should read...
write a c++ program that prompts a user to enter 10 numbers. this program should read the numbers into an array and find the smallest number in the list, the largest numbers in the list the sum of the two numbers and the average of the 10 numbers PS use file I/o and input error checking methods
Write a program in Easy68K: a) Define an array of numbers in the memory. b) Read...
Write a program in Easy68K: a) Define an array of numbers in the memory. b) Read two numbers from keyboard. The first number is the size of the array and the second number is what index of the array you want to access. The index you entered can be larger than the array. c) Display the element indexed by (index % size) in the array.
C++. Write a program that will read in id numbers and place them in an array.The...
C++. Write a program that will read in id numbers and place them in an array.The array is dynamically allocated large enough to hold the number of id numbers given by the user. The program will then input an id and call a function to search for that id in the array. It will print whether the id is in the array or not. Sample Run: Please input the number of id numbers to be read 4 Please enter an...
Write a C++ program to read N numbers. Find sum, product, and average of N numbers
Write a C++ program to read N numbers. Find sum, product, and average of N numbers
Using C# visual basics Can someone show a calculator with a button that does a FOR...
Using C# visual basics Can someone show a calculator with a button that does a FOR LOOP about 10x time and does a print out of a name 10x
Write a C++ program that does the following: Read and input file containing the following PersonAName,...
Write a C++ program that does the following: Read and input file containing the following PersonAName, PersonBName, XA,YA, XB, YB where the coordinates of PersonA in a 100 by 100 room is XA, YA and the coordinates of PersonB is XB, YB. Use square root function in cmath sqrt() to calculate the shortest distance between two points. A file will be uploaded in this assignment that will list coordinates of two people. The program should use a function call that...
Write Visual Basic program that seperates all natural numbers up to 863 value with a comma...
Write Visual Basic program that seperates all natural numbers up to 863 value with a comma side by side and show on the screen Please write readable.Thankss
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT