You are on page 1of 2

Gujarat Technological University

Sarvajanik College of Engineering & Technology


B.E. –II, SEM - IV (Computer Engineering)
Subject : Object Oriented Programming -I (3140705)

Unit 1: Introduction to java

1 Write a program to enter two numbers and perform mathematical operations on


them.

2 Write a program to convert rupees to dollar. 60 rupees=1 dollar.

Unit 2: Selections , Mathematical functions and loops:

1 The two roots of a quadratic equation ax2 + bx + c = 0 can be obtained using the
following formula:

b2 - 4ac is called the discriminant of the quadratic equation. If it is positive, the


equation has two real roots. If it is zero, the equation has one root. If it is negative,
the equation has no real roots.
Write a program that prompts the user to enter values for a, b, and c and displays
the result based on the discriminant. If the discriminant is positive, display two roots.
If the discriminant is 0, display one root. Otherwise, display “The equation has no
real roots”.

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.

4 Write a program that calculates percentage marks of the student if marks of 6


subjects are given.

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.

8 Write a program to find that given number or string is a palindrome or not

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.

10 Write an interactive program to print a string entered in a pyramid form. For


instance, the string “stream” has to be displayed as follows:
S
St
Str
Stre
Strea
Stream

11 Write an interactive program to print a string entered in a pyramid form. For


instance, the string “stream” has to be displayed as follows:
S
St
Str
Stre
Strea
Stream

12 Write an interactive program to print a diamond shape. For example, if user enters
the number 3, the diamond will be as follows:
*
**
***
****
***
**
*

You might also like