Programming & Computer Science Answers

C++ 9913
Python 5288
Java | JSP | JSF 3611
C 1680
C# 1362
Computer Networks 989
Algorithms 652
Databases | SQL | Oracle | MS Access 641
HTML/JavaScript Web Application 588
Other 537
Visual Basic 358
Assembler 209
Software Engineering 202
AJAX | JavaScript | HTML | PHP 166
MatLAB 150
MatLAB | Mathematica | MathCAD | Maple 124
Action Script | Flash | Flex | ColdFusion 112
UNIX/Linux Programming 89
Web Development 73
Excel 36
ASP | ASP.NET 23
Delphi | Pascal 21
Perl 16
Prolog 9
Functional Programming 9
MathCAD 5
Wolfram Mathematica 4
WPF 4
Ruby | Ruby on Rails 3
NodeJS Web Application 2

Questions answered by Experts: 26 876

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Search

Write a program that prompts the user to input a sequence of characters and outputs the number of vowels.

(Use the function isVowel written in Programming Exercise 2.)

Your output should look like the following:

There are # vowels in this sentence.

... where # is the number of vowels.


Write a value-returning function, isVowel, that returns the value true if a given character is a vowel and otherwise returns false.

For the input E, your output should look like the following:

E is a vowel: 1

When printing the value of a bool, true will be displayed as 1 and false will be displayed as 0.



Write a program that uses the function isPalindrome. Test your program on the following strings:

madam, abba, 22, 67876, 444244, trymeuemyrt

Modify the function isPalindrome of Example 6-6 so that when determining whether a string is a palindrome, cases are ignored, that is, uppercase and lowercase letters are considered the same.

The isPalindrome function from Example 6-6 has been included below for your convenience.

bool isPalindrome(string str) 
{
int length = str.length(); 
for (int i = 0; i < length / 2; i++) {
    if (str[i] != str[length – 1 – i]) {
         return false;
    } // if    
  } // for loop
 return true;
}// isPalindrome




Write a program that uses while loops to perform the following steps:

  1. Prompt the user to input two integers: firstNum and secondNum
  • (firstNum must be less than secondNum).
  1. Output all odd numbers between firstNum and secondNum.
  • Separate each number with a space
  1. Output the sum of all even numbers between firstNum and secondNum.
  2. Output the numbers and their squares between 1 and 10.
  3. Output the sum of the square of the odd numbers between firstNum and secondNum.
  4. Output all uppercase letters.
  • Separate each letter with a space

Write a program that prompts the user to enter a telephone number expressed in letters and outputs the corresponding telephone number in digits.

If the user enters more than seven letters, then process only the first seven letters.

Also output the - (hyphen) after the third digit.

Allow the user to use both uppercase and lowercase letters as well as spaces between words.

Moreover, your program should process as many telephone numbers as the user wants.


The program should accept input and produce output similar to the example program execution below.

Enter Y/y to convert a telephone number from
letters to digits.
Enter any other letter to terminate the program.
Y
Enter a telephone number using letters: Hello world

The corresponding telephone number is:
435-5696
To process another telephone number, enter Y/y
Enter any other letter to terminate the program.
z

Write a program that mimics a calculator. The program should take as input:

  1. Two floating-point numbers
  2. The operation to be performed (+, -, /, *).

It should then output the numbers, the operator, and the result.

Additional notes:

  • Format your output to two decimal places.
  • For division, if the denominator is zero, output an appropriate message. The message should contain the word "error"

Some sample outputs follow:

3.5 + 4.0 = 7.50
13.973 * 5.65 = 78.95

Write a program that mimics a calculator. The program should take as input:

  1. The first integer
  2. The second integer
  3. The operation to be performed (+, -, *, /)

It should then output the numbers, the operator, and the result. (For division, if the denominator is zero, output an appropriate message. The message should contain the word "error")

Some sample outputs follow:

3 + 4 = 7
13 * 5 = 65

Instructions

Write a program that prompts the user to input a number. The program should then output the number and a message saying whether the number is positive, negative, or zero.


Interest on a credit card’s unpaid balance is calculated using the average daily balance.

Suppose that netBalance is the balance shown in the bill, payment is the payment made, d1 is the number of days in the billing cycle, and d2 is the number of days payment is made before billing cycle.

Then, the average daily balance is:

averageDailyBalance = (netBalance * d1 – payment * d2) / d1

If the interest rate per month is, say, 0.0152, then the interest on the unpaid balance is:

interest = averageDailyBalance * 0.0152 

Instructions

Write a program that accepts as input netBalance, d1, payment, d2, and interest rate per month (interestRate).

The program outputs the interest.

Format your output to two decimal places.


Write a program that accepts as input the mass, in grams, and density, in grams per cubic centimeters, and outputs the volume of the object using the formula: volume = mass / density.

Format your output to two decimal places.


LATEST TUTORIALS
APPROVED BY CLIENTS