Professional Documents
Culture Documents
1 The two roots of a quadratic equation ax2 + bx + c = 0 can be obtained using the
following formula:
2 A shipping company uses the following function to calculate the cost (in dollars) of
shipping based on the weight of the package (in pounds).
Write a program that prompts the user to enter the weight of the package and
display the shipping cost. If the weight is greater than 50, display a message “the
package cannot be shipped.”
3 Write a program to enter two numbers and implement calculator using switch.
5 Write a program to find length of string and print the second half of the string.
6 Write a program to accept a line and check how many consonants and vowels are
there in line.
7 Write a program to count the number of words that start with capital letters.
9 Create a class which ask the user to enter a sentence, and it should display count
of each vowel type in the sentence. The program should continue till user enters a
word “quit”. Display the total count of each vowel for all sentences.
12 Write an interactive program to print a diamond shape. For example, if user enters
the number 3, the diamond will be as follows:
*
**
***
****
***
**
*