Question

In: Computer Science

Use Visual Basic Language In this assignment you will need to create a program that will...

Use Visual Basic Language

In this assignment you will need to create a program that will have both a “for statement” and an “if statement”. Your program will read 2 numbers from the input screen and it will determine which is the larger of the 2 numbers. It will do this 10 times. It will also keep track of both the largest and smallest numbers throughout the entire 10 times through the loop. An example of the program would be the first time through the loop; you input the number 10 and 50. The program would respond with 50 being the larger of the two. You next would input 100 and 75. The program would then respond with 100 being the larger of the two. Upon the 10th time through the loop the program would determine not only which number is the largest but also what was the largest number in the session and which was the smallest number in the session. In this example we only did two loops through the session but the correct answer at this point would be the largest number as 100 and the smallest as 10.

A few hints...

• Create variable

o Num1

o Num2

o Lownum

o Highnum

For loop will be 1 to 10

• If statements

If num1 > num2 then

Console.writeline(“Number 1 is larger ” & Num1)

o Else Console.writeline(“Number 2 is larger ” & Num2)

o End if

If statement to check high and low

If num1 > highnum then

Highnum = num1

o End if

If num1 < lownum then

Lownum = numn1

o End if

o Don’t forget num2

Solutions

Expert Solution

Application Name :VB_Numbers_ConsoleApp

Application Type :Console Application

Language used :VB

Module1.vb :

Module Module1 'VB Module

Sub Main() 'Main() procedure
'declaring variables
Dim num1 As Integer
Dim num2 As Integer
Dim lowNum As Integer
Dim highNum As Integer
'using for loop
For i = 1 To 10
'asking user two numbers
Console.Write("Enter numbers 1 : ")
'reading numbers
num1 = Integer.Parse(Console.ReadLine())
Console.Write("Enter numbers 2 : ")
num2 = Integer.Parse(Console.ReadLine())
'using If else checking numbers
If num1 > num2 Then
'when num1 is greater than num2 then
Console.WriteLine(“Number 1 is larger ” & num1)
If i = 1 Then 'this code snippet is used for high and low num
highNum = num1
lowNum = num2
End If
Else
'when num2 is greater than num1 then
Console.WriteLine(“Number 2 is larger ” & num2)
If i = 1 Then 'this code snippet is used for high and low num
highNum = num2
lowNum = num1
End If
End If

'checking number for high
If num1 > highNum Then
'when num1 is greater than highnum
highNum = num1
End If
'checking number for low
If num1 < lowNum Then
'when num1 is less than lowNum
lowNum = num1
End If
'checking number for high
If num2 > highNum Then
'when num2 is greater than highnum
highNum = num2
End If
'checking number for low
If num2 < lowNum Then
'when num2 is less than lowNum
lowNum = num2
End If
Next
'print High number
Console.WriteLine("highNum : " & highNum)
Console.Write("lowNum : " & lowNum) 'print low num
End Sub

End Module
======================================

Output :


Related Solutions

Use Visual Basic Language In this assignment,you will create the following data file in Notepad: 25...
Use Visual Basic Language In this assignment,you will create the following data file in Notepad: 25 5 1 7 10 21 34 67 29 30 You will call it assignment4.dat and save it in c:\data\lastname\assignment4\. Where lastname is your last name. The assignment will be a console application that will prompt the user for a number. Ex. Console.Write(“Enter a number: ”) And then read in the number Ex. Number = Console.ReadLine() You will then read the data file using a...
Make a Console application Language should be Visual Basic In this assignment, you will be calculating...
Make a Console application Language should be Visual Basic In this assignment, you will be calculating the two parts for each month. you calculate the interest to pay each month and principal you pay every month. The interest you pay every month = loan * monthlyInterest The principal you pay every month = monthlyMortgage -  interest you pay every month ' what is my remaining loan loan = loan - principal you pay every month Problem 1 : Using While Loop,...
Language: c++ using visual basic Write a program to open a text file that you created,...
Language: c++ using visual basic Write a program to open a text file that you created, read the file into arrays, sort the data by price (low to high), by box number (low to high), search for a price of a specific box number and create a reorder report. The reorder report should alert purchasing to order boxes whose inventory falls below 100. Sort the reorder report from high to low. Inventory data to input. Box number Number boxes in...
a) Create a program for the msp430FR6989 .You will use need to program it to be...
a) Create a program for the msp430FR6989 .You will use need to program it to be able to use a external pulse switch to start/stop the blinking of LED1, and a second pulse switch to control the blinking of LED2. b) Modify Program #1 (b) to blink the number of times on the data switches once the pulse switch is engaged
USE VISUAL BASIC / VB You will create a datafile with the following information: 70 80...
USE VISUAL BASIC / VB You will create a datafile with the following information: 70 80 90 55 25 62 45 34 76 105You will then write the program to read in the values from the datafile and as you read in each number, you will then evaluate it through an if statement for the weather of the day. For example, when you read in the value 70 from the datafile, you should print to the screen that the temperature...
Description: To create a Visual Basic program that will obtain a sentence from the user, parse...
Description: To create a Visual Basic program that will obtain a sentence from the user, parse the sentence, and then display a sorted list of the words in the sentence with duplicate words removed. Tasks: Design a method (algorithm) to solve the above problem using pseudocode or a flowchart. Translate your algorithm into an appropriate VB program and test it using the following input sentence. "We are the world We are the children" Submit: Pseudocode version of algorithm/Flowchart version of...
Program on Visual Basic, VBA Create an application that lets the user enter a number of...
Program on Visual Basic, VBA Create an application that lets the user enter a number of seconds and produces output according to the following criteria: There are 60 seconds in a minute. If the number of seconds entered by the user is greater than or equal to 60, the program should display the number of minutes in that many seconds. There are 3,600 seconds in an hour. If the number of seconds entered by the user is greater than or...
USE VISUAL STUDIO/VB In this assignment, you will create an array of ten elements, one for...
USE VISUAL STUDIO/VB In this assignment, you will create an array of ten elements, one for name, one for hours worked,and the last for hourly rate. The arrays will receive the information from inputs from the screen.For example, you will ask the following three questions: a) Employee name: b) Hours worked: c) Hourly rate: After you have received all ten records and have inserted them into the array, you will then calculate the hourly rate times the hours worked to...
Language: Java Create a TryIt.java program with a main method. You are going to use this...
Language: Java Create a TryIt.java program with a main method. You are going to use this program to demonstrate some things about how Java works. Make your methods here private, because they are not intended to be called from outside the program. For each test below, make sure that you print to the console: 1) What is being tested 2) The desired output 3) The actual output Question to be answered: Should you use == or the String method equals...
In c# I need to create a simple payroll management system using visual basic and GUI....
In c# I need to create a simple payroll management system using visual basic and GUI. I also need to connect to SQL database. It needs a log in screen, inside the login screen it needs another screen to enter or edit employee information. It needs somewhere to enter hours worked for that specific employee, and another screen that can access reports.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT