Explanation of Solution
Given: The following lines of code that contains a list box in which the font of the output is set to ‘Courier New’:
Dim fmtStr As String = "{0,-7} {1,-7:N1} {2,-7:P1}" 'Two spaces IstOutput.Items.Clear()
IstOutput.Items.Add("12345678901234567890") IstOutput.Items.Add(String.Format(fmtStr, "Element", "Weight", "Percent")) IstOutput.Items.Add(String.Format(fmtStr, "Oxygen", 97.5, 97.5 / 150)) IstOutput.Items.Add(String.Format(fmtStr, "Carbon", 27, 27 / 150))
To find: The output produced by the given lines of code.
Dim fmtStr As String = "{0,-7} {1,-7:N1} {2,-7:P1}" 'Two spaces IstOutput.Items.Clear()
IstOutput.Items.Add("12345678901234567890") IstOutput.Items.Add(String.Format(fmtStr, "Element", "Weight", "Percent")) IstOutput.Items.Add(String.Format(fmtStr, "Oxygen", 97.5, 97.5 / 150)) IstOutput.Items.Add(String.Format(fmtStr, "Carbon", 27, 27 / 150))
Solution:
The given lines of code will show “123456789012345678901234567890 Element Weight Percent Oxygen 97.5 65.0 % Carbon 27.0 18.0 %� as output in the list box named “IstOutput� because the method named “Add� will add the items to the list. The value “123456789012345678901234567890� will be concatenated with “Element�, “Weight�, “Percent�, "Oxygen", "97...
Trending nowThis is a popular solution!
Chapter 3 Solutions
Introduction To Programming Using Visual Basic (11th Edition)
- Q7arrow_forwardConvert Months Write a program that allows the user to enter a whole number of monthsand then converts that amount of time to years and months. See Fig. 3.38. The programshould use both integer division and the Mod operator.arrow_forward1c) Average sentence length We will create a function ( avg_sentence_len ) to calculate the average sentence length across a piece of text. This function should take text as an input parameter. Within this function: 1. sentences : Use the split() string method to split the input text at every '." variable sentences . To keep things simple, we will consider every "." as a sentence separator. (This decision could lead to misleading answers. For example, "Hello Dr. Jacob." is actually a single sentence, but our function will consider this 2 separate sentences). 2. words : Use the split() method to split the input text into a list of separate words, storing this in words . Again, to limit complexity, we will assume that all words are separated by a single space (" "). (So, while "I am going.to see you later" actually has 7 words, since there is no space after the ".", so This will split the text into a list of sentences. Store this in the we will assume the this to contain 6 separate words…arrow_forward
- 2. write a program that enters and displays elements of x(10,10) and then displays the factorial of the sum of numbers in the secondary diagonal elements in the message box.arrow_forwardCategory ART_AND_DESIGN Rating Reviews App Photo Editor & Candy Camera & Grid & ScrapBook Coloring book moana U Launcher Lite – FREE Live Cool Themes, Hide Apps ART_AND_DESIGN Sketch - Draw & Paint FIND SEARCH 4.1 159 The FIND function returns the position (as a number) of one text string inside another. When the text is not found, FIND ART_AND_DESIGN 3.9 967 4.7 87510 returns a #VALUE error. ART_AND_DESIGN ART_AND_DESIGN ART_AND_DESIGN ART_AND_DESIGN ART_AND_DESIGN ART_AND_DESIGN ART_AND_DESIGN ART_AND_DESIGN ART_AND_DESIGN ART_AND_DESIGN ART_AND_DESIGN ART_AND_DESIGN ART_AND_DESIGN ART_AND_DESIGN ART_AND_DESIGN ART_AND_DESIGN ART_AND_DESIGN ART_AND_DESIGN 4.5 215644 Pixel Draw - Number Art Coloring Book Paper flowers instructions 4.3 967 The SEARCH function returns the location of one text string inside another. SEARCH returns the position of the first 4.4 167 character of find_text inside within_text. Unlike FIND, SEARCH allows wildcards, and is not case-sensitive. Smoke Effect…arrow_forwardfor( ( } total = total + number; Fig. 2 Finish the for loop in Fig. 2. The loop will total the variable number six times. Given: float number; float total; int cnt; Edit View Insert Format Tools Table 12pt ✓ Paragraph v BI U Av ev T² 00 0 EV G ģ :arrow_forward
- 1. The main function creates 5 pixels with random red, green, and blue values. Complete the id_color function to return “red” if the red value is greater than the green and blue, “green” if the green value is greater than the red and blue, and “blue” if the blue value is greater than the red and green. If there is no clear maximum value (for example, if the red and green values are the same) return None. Do not change the main function.arrow_forward1. The main function creates 5 pixels with random red, green, and blue values. Complete the id_color function to return “red” if the red value is greater than the green and blue, “green” if the green value is greater than the red and blue, and “blue” if the blue value is greater than the red and green. If there is no clear maximum value (for example, if the red and green values are the same) return None. Do not change the main function. import imageimport random def id_color(p):'''Returns the dominant color of pixel p'''pass#Your code here to determine the dominant color and return a string identifying it#Hint: get the red, green & blue values and use an if statement to determine which has the highest value def main():'''Controls the program'''for i in range(5): #Loop 5 timesr = random.randrange(0, 256)g = random.randrange(0, 256)b = random.randrange(0, 256)print(r, g, b) #Show the pixel red, green & blue valuesnew_pixel = image.Pixel(r, g, b)print(id_color(new_pixel)) main()…arrow_forward***required width for Celsius value is 35, width Fahrenheit value is 35, both should be right-aligned/justified # convert_revised_1.py # We will try to print a table without using "string formatting"def main():print("celsius", "fahrenheit") for celsius in range (-50, 200, 20):fahrenheit = 9/5 * celsius + 32print(celsius, fahrenheit) revise the TWO print statements, one is before the "for loop", for Table Header another one is within the "for loop".arrow_forward
- Python graphicsarrow_forwardGrowth of an Investment Suppose a fixed amount of money is deposited at the beginning of each month into an investment paying 6% interest compounded monthly. After each deposit is made, [new balance]=1.005∗[previous balance one month ago]+ [fixed amount]. Write a program that requests the fixed amount of the deposits as input and displays the balance after each of the first four deposits. See Fig. 5.14.arrow_forwardDabugging Exercises 1. What is wrong with the following pseudocode? 11 This program assigns a character to the first element in il a string. Declare String letters Set letters[0] Display "The first letter of the alphabet is ", "A" %3D lettersarrow_forward
- Programming with Microsoft Visual Basic 2017Computer ScienceISBN:9781337102124Author:Diane ZakPublisher:Cengage LearningMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,