--%>

Programming with C#

QUESTION 1      

The following UML diagram describes an abstract class Customer. This class is to be used as part of a Company's inventory system. The inventory system will contain many different types of customers.  A separate subclass of Customer will be written for each type of customer. Once a customer is created, their identification will never change.

Using the given information and the UML diagram below you are to write the C# code for the Customer class only.

 

Customer {abstract}

 

 

-identification : string

-name : string

-address : string

 

 

+Customer(id : string, name : string, address : string)

+GetIdentification(): string

+GetName(): string

+SetName(name : string)

+GetBillingType():BillingType {abstract}

 

QUESTION 2                                                                                                

Write a method using the method header below.

   public void Reverse( double [] values, int start, int finish){ 

This method will reverse the elements in an array between a lower index position and an upper index position.

So given the following array declaration

                double [] data = {8.5, 12.0, 23.2, 18.0, 15.5, 5.0, 10.5};

following a call to the method Reverse(data, 2, 5); the contents of data would be

                {8.5, 12.0, 5.0, 15.5, 18.0, 23.2, 10.5}

Assume that you have already written a method called swap that swaps two elements in an array; the elements identified by the two index values passed as parameters:

Swap(array, oneIndex, otherIndex)

QUESTION 3                                                                                    

(a)          Write a method, IsVowel, which returns the value true if the supplied lowercase character is a vowel, otherwise return false. Use the following method heading.

                ///

      /// pre: ch is a lowercase alhpabethic character

                ///                           'a' <= ch <= 'z'

                ///

                /// post: returns true is ch is a vowel, otherwise false

      ///

      ///

      /// true if ch is in {'a', 'e', 'i', 'o', 'u'}

public bool IsVowel(char ch)

Note: only the lowercase letters, a, e, i, o, u are vowels. There is no need to include the XML comment in your answer.

(b)          In the formulation of a test plan for the method isVowel, what would be two (2) obvious test categories to include in the test plan?

QUESTION 4                                                                                                     

A common operation on a list is to find the "largest" value in a list.  Write an algorithm which will find the "second largest" value in a list. You can assume that the list will contain at least 2 values and that no value is duplicated.  Do not write C# code as your answer, but the algorithm should be at a level of detail that would lend itself to implementation in C# or any other programming language.

The algorithm should not make use of any supplied functionality, e.g. C# Array class methods such as Sort etc. It is also assumed that this algorithm would be implemented as a method which returns the location of the second largest value of the list and that the order of the values within the list is unchanged. This means that one cannot simply sort the array in ascending order and return (list.Length-2) as it is assume that the list will be passed by reference to this method.

 

 

 

 

 

   Related Questions in Programming Languages

  • Q : What is BLAST in program model checking

    What is BLAST in program model checking: The abbreviation is Berkeley Lazy Abstraction Software Verification Tool (BLAST) is a software model checker for C programs. The main goal of BLAST (BLAST website) is to be able to check that software satisfies

  • Q : Explain Do loop Do loop : This is one

    Do loop: This is one of Java's three control structures employed for looping. The other two are the for loop and while loop. A do loop comprises of a loop body and a Boolean expression. The condition is tested subsequent to the loop body has been fini

  • Q : Define the term Address space Define

    Define the term Address space: The region of virtual memory in which a procedure is run.

  • Q : What are the uses of microcontroller

    What are the uses of microcontroller?

  • Q : What is an Operand Operand : An operand

    Operand: An operand is an argument of the operator. Expressions comprise combinations of operands and operators. The value of an expression is determined by exerting the operation stated by each and every operator to the value of its operands.

  • Q : Define Hexadecimal Hexadecimal : Number

    Hexadecimal: Number representation in hexadecimal is base 16. In base 16, the digits 0-9 and the letters A to F are utilized. A symbolizes 10 (base 10), B symbolizes 11 (base 10), and so forth. Digit positions symbolize successive pow

  • Q : Define Sign bit Sign bit : In

    Sign bit: In 2s-complement notation, the most important bit in an integer value is employed to determine the sign of the value. A 1-bit point out a negative number and a 0 bit point out a positive number.

  • Q : Describe Real number Real number : It

    Real number: It is a number with an integer and a fractional portion. The primitive types double and float are employed to symbolize real numbers.

  • Q : Describe the Binders Briefly describe

    Briefly describe the Binders?

  • Q : Model Java Interface applications What

    What wide range of applications are provided by Model Java Interface?