Question

In: Computer Science

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.

Solutions

Expert Solution

Program:

Module Module1

Sub Main()
Dim num As Integer
Dim i As Integer
Dim greater, less As Integer
Dim temp As Integer


For i = 1 To 5

Console.Write("Enter Number" & i & ": ")
num = Convert.ToInt32(Console.ReadLine())

If (i = 1) Then
greater = num
less = num
ElseIf (greater < num) Then
greater = num
Console.WriteLine("Greater")
ElseIf (less > num) Then
less = num
Console.WriteLine("Less")
ElseIf greater > less Then
Console.WriteLine("Greater")
Else
Console.WriteLine("Less")
End If


Next i

Console.WriteLine("-----------------------------------" & vbNewLine)
Console.WriteLine("Largest Number: " & greater)
Console.WriteLine("Smallest Number: " & less)

Console.ReadKey()
End Sub

End Module


Related Solutions

java Problem 3: An Interesting Problem Write a program that accepts two positive integers: a deposited...
java Problem 3: An Interesting Problem Write a program that accepts two positive integers: a deposited amount of money and an interest rate, as an annual percentage rate. Your program will calculate the number of years that will take for the account balance to reach $1, 000,000. You can assume that the initial deposit is less than $1,000,000 Input The input will begin with a single line containing T , the number of test cases to follow. The remaining lines...
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.
Write a complete MiniMIPS program that accepts a seqeunce of integers at input and after the...
Write a complete MiniMIPS program that accepts a seqeunce of integers at input and after the receipt of each new input value, displays the largest and smallest integers thus far. An input of 0 indicates the end of input values and is not an input value itself. Note that you do not need to keep all integers in memory.
Im just having some trouble using functions in visual basics. Could you please explain what Im...
Im just having some trouble using functions in visual basics. Could you please explain what Im doing wrong? I think it has to do with the calling of the function. Public Class Form1     Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click         Me.Close()     End Sub     Private Function Rsumation(ByVal intx As Integer) As Double         intx = CInt(Txtinput.Text)         If intx = 1 Then             Return 1         Else Return (intx + Rsumation(intx - 1))        ...
specifications for Tasks: 1. Write a program which accepts a list of integers which may contain...
specifications for Tasks: 1. Write a program which accepts a list of integers which may contain duplicated integers, and which outputs the input list as a sorted list in ascending order without duplication You can use either Ruby, C, C++, C# or Java to implement your program (referred to as P). 2. Design a test suite of 10 test cases (referred to as TC). Each test case has not more than 20 integers. 3. Test P against TC to make...
Im confused with this lab? 2.12 LAB: Divide by x Write a program using integers user_num...
Im confused with this lab? 2.12 LAB: Divide by x Write a program using integers user_num and x as input, and output user_num divided by x three times. Ex: If the input is: 2000 2 Then the output is: 1000 500 250
1) Write a function searchValue that accepts an array of integers, the size of the array,...
1) Write a function searchValue that accepts an array of integers, the size of the array, and an integer. Find the last occurrence of the integer passed in as an input argument in the array. Return the index of the last occurrence of the value. If the value is not found, return a -1 2) Write the line of code to call the previous function assuming you have an array vec with length n, and are looking for the number...
Problem Description: In C write a program that assigns random integers between 1 and 20 to...
Problem Description: In C write a program that assigns random integers between 1 and 20 to a 5 x 5 two-dimensional array then displays the array with average of each row in a table format and the total of all elements in the array. Also calculate the total of each diagonal, top left to bottom right and top right to bottom left. Display the largest of the diagonal’s totals. Example of the array: 6          10        3          19        20        1          17       ...
You should use Visual Studio to write and test the program from this problem.   Write a...
You should use Visual Studio to write and test the program from this problem.   Write a complete program with a for loop that (5 pts) uses proper variable types. (10 pts) uses a for loop to read in a real numbers exactly 8 times (10 pts) adds the number read in the loop to a running sum. (10 pts) Computes the average of the 8 numbers as a real number. (5 pts) Prints the correct result with 2 decimal places,...
/** * Write a recursive function that accepts a stack of integers and * replaces each...
/** * Write a recursive function that accepts a stack of integers and * replaces each int with two copies of that integer. For example, * calling repeatStack and passing in a stack of { 1, 2, 3} would change * the stack to hold { 1, 1, 2, 2, 3, 3}. Do not use any loops. Do not use * any data structures other than the stack passed in as a parameter. * @param stack */ public static void...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT