Question

In: Computer Science

In Visual Basics 6.Two String returning functions to have nice looking output for numbers/money are? 7.Where...

In Visual Basics

6.Two String returning functions to have nice looking output for numbers/money are?

7.Where do we place a class-level variable declaration, and where is it accessible from?

8.Two forms of parameter passing:

9.FULLY define an array:

10.Show the VB code to declare an initialize an array called Ar1 of Integers to hold the value of 5, 10 and 15.

11. For Ar1above, Ar1.Count = ________ and legal index values are:_____ to ______.

12.Show the VB code to declare an initialize an array Ar2 of Integers to hold 50 zeros.

13. Now write a for loop to set Ar2 to hold the values 0, 1, 2, etc, to 49 [Do NOT hardwire a “49” into thisfor-loop but rather use an expression for the upper bound]. (Hint: 3 lines)

14.Show the VB code to declare an array Ar3 of Strings with size and content to be determined later.

15.Show the VB line needed to fill Ar3 (from above) with the contents of a text file called

“C:\VB2010\MyData.txt”.

Solutions

Expert Solution

Dear Student ,

As per the requirement submitted above , kindly find the below solution.

Question 6 :

Answer :

  • String.Format() can be used to format the output.

****************************

Question 7 :

Answer :

  • Class level variables are declared inside the class but outside of any method.
  • These variables can be accessed inside the class or outside the class that is in the another class.

****************************

Question 8 :

Answer :

  • Call by Value
  • Call by reference

In vb arguments can be passed by value or passed by reference.

****************************

Question 9 :

Answer :

  • Array in vb can store same type of elements
  • Array index starts with zero.
  • Syntax :Dim arrayName() as DataType
  • Example :Dim a() as Integer
  • Above is integer array

****************************

Question 10 :

Answer :Dim Ar1 As Integer() = {5, 10, 15}

****************************

Question 11 :

Answer :

Ar1.Count=3

legal index values are: 0 to 2.because array index starts with 0.

****************************

Question 12 :

Answer : Dim Ar2 As Integer() =
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,0}

****************************

Question 13 :

Answer :

For i = 0 To 49
Ar2(i) = i
Next

This For loop will fill value of i as an array element from 0 to 49

****************************

Question 14 :

Answer : Dim Ar3() As String

This code snippet will create an array of String

****************************

Question 15 :

Answer :Dim Ar3() As String = System.IO.File.ReadAllLines("C:\VB2010\MyData.txt")

Above code snippet will read all lines from the file and store it in the array

****************************

NOTE : PLEASE FEEL FREE TO PROVIDE FEEDBACK ABOUT THE SOLUTION.


Related Solutions

2. Create ACCESSOR FUNCTIONS in JAVA a) String moneyToString(int[] money); // Returns a nice looking string....
2. Create ACCESSOR FUNCTIONS in JAVA a) String moneyToString(int[] money); // Returns a nice looking string. Ex, "$6.25", "$0.21", "$4.01", "$2.00". MAKE SURE TO CONSIDER ALL EXAMPLES! b) *String moneyToText(int[] money); // Returns the Money as words. Ex,{123,51} => "one hundred and twenty three dollars and fifty one cents." YOU MAY ASSUME money <$1000. context: this is what I have so far package com.company; import java.util.*; public class Main { public static void main(String[]args) { int money[] = createMoney(12, 34);...
Let n be a positive integer. Prove that two numbers n2+3n+6 and n2+2n+7 cannot be prime...
Let n be a positive integer. Prove that two numbers n2+3n+6 and n2+2n+7 cannot be prime at the same time.
create a C++ program where you have 2 functions with two parameters. Limit the first function...
create a C++ program where you have 2 functions with two parameters. Limit the first function allowed input to values of numbers from 1-10 and from 5 to 20 for the second function. have each function add their two-parameter together then add the functions final values together. Show error message if wrong input is entered   Ask the user if they wish to continue the program (use loop or decision for this question).
You have access two 7-segment decoder outputs from an existing circuit. These outputs show the numbers...
You have access two 7-segment decoder outputs from an existing circuit. These outputs show the numbers 00 through 15. Build a circuit to convert the two 7-segment displays, which display decimal, to one 7- segment display, which displays the correct hexadecimal number.   
You have 2 dimes, 6 nickels, and 7 pennies in your pocket. You randomly remove two...
You have 2 dimes, 6 nickels, and 7 pennies in your pocket. You randomly remove two coins without replcement? 1. What is the probability that both of them are nickels? 2. What is the probability that the first is a nickel and the second is a dime?
Consider a two factor model of expected returns where the risk free rate is 6% and the expected risk premiums on the factor portfolios are 3% and 7%.
Consider a two factor model of expected returns where the risk free rate is 6% and the expected risk premiums on the factor portfolios are 3% and 7%. If the factor portfolios are “ideal” and tradable, determine if an arbitrage opportunity exists for the portfolio given below and specify how can it be exploited.portfolioBf1Bf2Expected returnA1.40.80.41  
Given the expected return of 12% for stocks and 6% for bonds, your retirement account is split between those two asset classes, how much money would have when you retire if you put in $5,000 each year and you work for 40 years?
Given the expected return of 12% for stocks and 6% for bonds, your retirement account is split between those two asset classes, how much money would have when you retire if you put in $5,000 each year and you work for 40 years? How much would you have if you put all your money in bonds? Or all your money in stocks?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT