An array of integers named parking Tickets has been declared and initialized to the number of parking tickets given out by the city police each day since the beginning of the current year. (Thus, the first element of the array contains the number of tickets given on January 1; the last element contains the number of tickets given today.) A variable named mostTickets has been declared, along with a variable k. Without using any additional variables, write some code that results in mostTickets containing the largest value found in parkingTickets.

Visual Basic

LANGUAGE: Visual Basic CHALLENGE: An array of integers named parking Tickets has been declared and initialized to the number of parking tickets given out by the city police each day since the beginning of the current year. (Thus, the first element of the array contains the number of tickets given on January 1; the last element…

Read More

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 use only k, incompletes, studentID, and numberOfIncompletes.

Visual Basic

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 use…

Read More

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 only j, k, zipcodeList, and duplicates.

Visual Basic

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 only…

Read More

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. Use only k, zipcodeList, and duplicates.

Visual Basic

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. Use…

Read More

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 otherwise. Use only k, currentMembers, memberID and isAMember.

Visual Basic

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 otherwise.…

Read More

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 a loop that reverses the elements of the array. Do not use any other variables besides a, k, and temp.

Visual Basic

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 a…

Read More

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.

Visual Basic

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 More

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.

Visual Basic

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 More

Write the code for a message whose method name is send Object.  There is one argument for this message, which is of type Customer.  Suppose there is an object of type Customer, called John_Doe.  Send this object within your message.

Visual Basic

LANGUAGE: Visual Basic CHALLENGE: Write the code for a message whose method name is send Object.   There is one argument for this message, which is of type Customer.   Suppose there is an object of type Customer, called John_Doe.   Send this object within your message.

Read More

 print Larger is a function that accepts two int parameters and returns no value.  Two int variables, sales 1 and sales 2, have already been declared and initialized.  Write a statement that calls printLarger, passing it sales1 and sales2.

Visual Basic

LANGUAGE: Visual Basic CHALLENGE:  print Larger is a function that accepts two int parameters and returns no value.   Two int variables, sales 1 and sales 2, have already been declared and initialized.   Write a statement that calls printLarger, passing it sales1 and sales2.

Read More