Posts Tagged ‘C++’
Write a recursive, bool-valued function, containsVowel, that accepts a string and returns true if the string contains a vowel.
LANGUAGE: C++ CHALLENGE: Write a recursive, bool-valued function, containsVowel, that accepts a string and returns true if the string contains a vowel. A string contains a vowel if: The first character of the string is a vowel, or The rest of the string (beyond the first character ) contains a vowel
Read MoreAssume the existence of a BankAccount class . Define a derived class , SavingsAccount that contains two instance variables : the first a double , named interestRate, and the second an integer named interestType.
LANGUAGE: C++ CHALLENGE: Assume the existence of a BankAccount class . Define a derived class , SavingsAccount that contains two instance variables : the first a double , named interestRate, and the second an integer named interestType. The value of the type variable can be 1 for simple interest and 2 for compound interest. There is also a constructor …
Read MoreWrite the definition of a function called product.
LANGUAGE: C++ CHALLENGE: Write the definition of a function called product . The function receives two int parameters. You may assume that neither parameter is negative. The function returns the product of the parameters . So, product (3,5) returns 15 and product (30,4) returns 120. The function must not use a loop of any kind…
Read MoreWrite a function called fact that recursively calculates the factorial value of its single int parameter.
LANGUAGE: C++ CHALLENGE: Write a function called fact that recursively calculates the factorial value of its single int parameter. The value returned by fact is a long ..
Read MoreRead in string and evaluate for word count and letter occurrences
LANGUAGE: C++ CHALLENGE: Write a program that will read in a line of text and output the number of words in the line and the number of occurrences of each letter. Define a word to be any string of letters that is delimited at each end by either a whitespace, a period, a comma, or the…
Read MoreC++ Sort Array in ascending Order
LANGUAGE: C++ CHALLENGE: Write a function, sort, that accepts an array of integers , and the number of elements in the array and sorts the array in ascending order (basic sort)
Read MoreC++ Define a class called Odometer that will track fuel and mileage for an automotive vehicle.
LANGUAGE: C++ CHALLENGE: C++ Define a class called Odometer that will track fuel and mileage for an automotive vehicle. The class should have member variables to track the miles driven and the fuel inefficiency of the vehicle in miles per gallon. Include a mutator function to reset the odometer to zero miles, a mutator function…
Read MoreC++ Read In Array with Fewer than 50 integers, sort, print Unique numbers and there number of occurrences.
LANGUAGE: C++ CHALLENGE: C++ Write a program that reads in an array of type int. You may assume that there are fewer than 50 entries in the array. Your program determines how many entries are used. The output is to be a two-column list. the first column is a list of the distinct array elements;…
Read More