Posts Tagged ‘Visual Basic’
Given an Integer variable k, an Integer array incompletes that has been declared and initialized, an int variable studenID that has been initialized, and an int variable numberOfIncompletes, write code that counts the number of times the value of studentID appears in incompletes and assigns this value to numberOfIncompletes.
LANGUAGE: Visual Basic CHALLENGE: Given an Integer variable k, an Integer array incompletes that has been declared and initialized, an int variable studenID that has been initialized, and an int variable numberOfIncompletes, write code that counts the number of times the value of studentID appears in incompletes and assigns this value to numberOfIncompletes. You may…
Read MoreYou are given two Integer variables j and k, an Integer array zipcodeList that has been declared and initialized, and a Boolean variable duplicates.
LANGUAGE: Visual Basic CHALLENGE: You are given two Integer variables j and k, an Integer array zipcodeList that has been declared and initialized, and a Boolean variable duplicates. Write some code that assigns True to duplicates if any two elements in the array have the same value, and that assigns False to duplicates otherwise. Use…
Read MoreYou are given an Integer variable k, an Integer array zipcodeList that has been declared and initialized, and a Boolean Variable duplicates.
LANGUAGE: Visual Basic CHALLENGE: You are given an Integer variable k, an Integer array zipcodeList that has been declared and initialized, and a Boolean Variable duplicates. Write some code that assigns True to duplicates if there are two adjacent elements in the array that have the same value, and that assigns False to duplicates otherwise.…
Read MoreGiven an Integer variable k, an Integer array currentMembers that has been declared and initialized, an Integer variable memberID that has been initialized, and a Boolean variable isAMember, write code that assigns True to isAMember if the value of memberID can be found in currentMembers, and that assigns false to isAMember otherwise.
LANGUAGE: Visual Basic CHALLENGE: Given an Integer variable k, an Integer array currentMembers that has been declared and initialized, an Integer variable memberID that has been initialized, and a Boolean variable isAMember, write code that assigns True to isAMember if the value of memberID can be found in currentMembers, and that assigns false to isAMember…
Read MoreReversing the elements of an array involves swapping the corresponding elements of the array: the first with the last, the second with the next to last, and so on, all the way to the middle of the array.
LANGUAGE: Visual Basic CHALLENGE: Reversing the elements of an array involves swapping the corresponding elements of the array: the first with the last, the second with the next to last, and so on, all the way to the middle of the array. Given an array a and two other Integer variables, k and temp, write…
Read MoreGiven an array temps of Doubles, containing temperature data, compute the average temperature.
LANGUAGE: Visual Basic CHALLENGE: Given an array temps of Doubles, containing temperature data, compute the average temperature. Store the average in a variable called avgTemp. Besides temps and avgTemp, you may use only two other variables — an Integer variable k and a Double variable named total, which have been declared.
Read MoreAssume that s is a string variable that is supposed to contain a value to be converted to integer.
LANGUAGE: Visual Basic CHALLENGE: Assume that s is a string variable that is supposed to contain a value to be converted to integer. Write a fragment of code that converts the value to integer variable and displays that value multiplied by 2. If the value cannot be converted, display the message ‘Invalid number’ instead.
Read MoreAssume that price is an integer variable whose value is the price (in US currency) in cents of an item.
LANGUAGE: Visual Basic CHALLENGE: Assume that price is an integer variable whose value is the price (in US currency) in cents of an item. Write a statement that prints the value of price in the form “S dollars and Y cents”. So, if the value of price was 4321,k you code would print “43 dollars…
Read MoreAssume that an int variable x has already been delared. Write an expression whose value is the last (rightmost) digit of x.
LANGUAGE: Visual Basic CHALLENGE: Assume that an int variable x has already been delared. Write an expression whose value is the last (rightmost) digit of x.
Read MoreAssume that price is an integer variable whose value is the price (in US currency) in cents of an item.
LANGUAGE: Visual Basic CHALLENGE: Assume that price is an integer variable whose value is the price (in US currency) in cents of an item. Assuming the item is paid for with a minimum amount of change and just single dollars, write an expression for the amount of change (in cents) that would have the be…
Read MoreWrite an expression that computes the remainder of the variable principal when divided by the variable divisor. (Assume both are type int.)
LANGUAGE: Visual Basic CHALLENGE: Write an expression that computes the remainder of the variable principal when divided by the variable divisor. (Assume both are type int.)
Read MoreAssume that price is an integer variable whose value is the price (in US currency) in cents of an item.
LANGUAGE: Visual Basic CHALLENGE: Assume that price is an integer variable whose value is the price (in US currency) in cents of an item. Assuming the item is paid for with a minimum amount of change and just single dollars, write an expression for the number of single dollars, write an expression for the number…
Read More