Question

In: Computer Science

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 is 70° and it is nice outside. After reading in all the values, you will determine which is the highest temperature and which is the lowest temperature. For example, your output will look like this:

The temperature for today is 70. It is nice outside.

The temperature for today is 80. It is getting warm outside.

The temperature for today is 90. It is hot outside.

The temperature for today is 55. It is cool outside.

The temperature for today is 25. It is really cold outside.

The temperature for today is 62. It is comfortable outside.

The temperature for today is 45. It is chilly outside.

The temperature for today is 34. It is cold outside.

The temperature for today is 76. It is nice outside.

The temperature for today is 105. It is really hot outside.

The high temperature for today is 105.

The low temperature for today is 25

Hints: You will need to create an if statement after you read your values in from the database to check the temperatures.

The ranges should be:

Above 100 –really hot

90-100 –hot

80-90 –getting warm

70-80 –nice

60-70 –comfortable

50-60 –cool

40-50 –chilly

30-40 –cold

20-30 –really cold

Below 20 –freezing

Notice that the number values such as 90 shows up in both selections. Instead of 90, one of them has to be 89 and so on. You will determine where the cutoffs are. Do not hard code the output information. Make sure you are running it through an if statement because my datafile will have different values than yours.

Solutions

Expert Solution

Below is the solution:

code:

Imports System.IO

Module Module1
    Sub Main()
        'declare the variabel
        Dim fileReader As String
        Dim dummyArray() As String
        Dim tempArray As New ArrayList
        fileReader = File.ReadAllText("temperature.txt")
        ' Part 2: split string based on spaces.
        dummyArray = fileReader.Split(New Char() {" "c})
        For Each value As String In dummyArray
            tempArray.Add(Convert.ToInt32(value)) 'convert each value to integer and store in arraylist
        Next
        'loop through each arraylist call the function to get the temperature details
        For Each num In tempArray
            tempDisplay(num)
        Next

        'declare a variable to find the highest temperature and lowest temperature
        Dim max As Integer = Integer.MinValue
        Dim min As Integer = Integer.MaxValue

        For Each element As Integer In dummyArray
            max = Math.Max(max, element)
            min = Math.Min(min, element)
        Next
        'display the high and low tepperature
        Console.WriteLine("The high temperature for today is " & max)
        Console.WriteLine("The low temperature for today is " & min)

        Console.ReadKey()


    End Sub
    'functon to display the teperature info
    Private Sub tempDisplay(num As Integer)
        'select case/switch case to get the info of the temperature
        Select Case num
            Case > 100
                Console.Write("The temperature for today is " & num & ". it is really hot outside.")
            Case 90 To 100
                Console.Write("The temperature for today is " & num & ". it is hot outside.")
            Case 80 To 90
                Console.Write("The temperature for today is " & num & ". it is getting warm outside.")
            Case 70 To 80
                Console.Write("The temperature for today is " & num & ". it is nice outside.")
            Case 60 To 70
                Console.Write("The temperature for today is " & num & ". it is comfortable outside.")
            Case 50 To 60
                Console.Write("The temperature for today is " & num & ". it is cool outside.")
            Case 40 To 50
                Console.Write("The temperature for today is " & num & ". it is chilly outside.")
            Case 30 To 40
                Console.Write("The temperature for today is " & num & ". it is cold outside.")
            Case 20 To 30
                Console.Write("The temperature for today is " & num & ". it is really cold outside.")
            Case < 20
                Console.Write("The temperature for today is " & num & ". it is freezing outside.")
        End Select
        Console.WriteLine()
    End Sub
End Module

sample output:


Related Solutions

You will create a datafile with the following information: 70 80 90 55 25 62 45...
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 is 70° and it is...
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...
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...
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...
create a Visual Basic project with the following features: 1. The user interface can display the...
create a Visual Basic project with the following features: 1. The user interface can display the following information, one textbox for one item: 1a. Author, in the form of Lastname, Firstname 1b. Title 1c. Source -- where the paper is published 1d. Abstract 1e. Publication year (This information is in the 1c. Source, but display the publication year separately here) 2. There is a command button "Import". It would allow the user to select the eric.txt as the input file...
Create programs in Visual Basic which perform each of the following: Explain the different design choices...
Create programs in Visual Basic which perform each of the following: Explain the different design choices (syntax) for option in each language Document the programs using Flowcharts Each programs source code must be included – label each with the language used a) Nested two-way selection statements b) Multiple-way selection statement c) Iterative Statements – Counter controlled and Logic controlled d) After the Counter Controlled Iterative successfully completes – Display “This was a success” on the screen.
Create programs in Visual Basic which perform each of the following: Explain the different design choices...
Create programs in Visual Basic which perform each of the following: Explain the different design choices (syntax) for option in each language Document the programs using Flowcharts Each programs source code must be included – label each with the language used a) Nested two-way selection statements b) Multiple-way selection statement c) Iterative Statements – Counter controlled and Logic controlled d) After the Counter Controlled Iterative successfully completes – Display “This was a success” on the screen.
windows forms Application using Visual Basic use visual basic 2012 Part 1: Programming – Income Tax...
windows forms Application using Visual Basic use visual basic 2012 Part 1: Programming – Income Tax Application 1.1 Problem Statement Due to upcoming end of financial year, you are being called in to write a program which will read in a file and produce reports as outlined. Inputs: The input file called IncomeRecord.txt contains a list of Annual income records of employees in a firm. Each record is on a single line and the fields are separated by spaces. The...
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...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT