You are on page 1of 5

Question 4 Write a class with name employee and basic as its data member, to find the gross pay

of an employee for the following allowances and deduction. Use meaningful variables. Dearness Allowance = 25% of the Basic Pay House Rent Allowance = 15% of Basic Pay Provident Fund = 8.33% of Basic Pay Net Pay = Basic Pay + Dearness Allowance + House Rent Allowance Gross Pay = Net Pay Provident Fund [15] Question 5 Write a program to input any given string to calculate the total number of characters and vowels present in the string and also reverse the string :- [15] Example : INPUT Enter String : SNOWY OUTPUT Total number of characters : 05 Number of Vowels : 01 Reverse string : YWONS Question 6 Write a program using a function called area() to compute the area of a : (i) circle(* r2) where = 3.14 (ii) square(side*side) (iii) rectangle ( length*breadth) Display the menu to output the area as per User's choice. [15] Question 7 Write a program to bubble sort the following set of values in ascending order: 5,3,8,4,9,2,1,l2,98,16 [15] OUTPUT : 1 2 3 4 5 8 9 12 16 98 Question 8 Write a program to print the sum of negative numbers, sum of positive even numbers and sum of positive odd numbers from a list of numbers(N) entered by the user. The list terminates when the user enters a zero. [15] Question 9 Write a program to initialize an array of 5 names and initialize another array with their respective telephone numbers. Search for a name input by the User, in the list. If found, display "Search Successful " and print the name along with the telephone number, otherwise display "Search unsuccessful. Name not enlisted". [15] Question 4 Write a program to calculate and print the sum of odd numbers and the sum of even numbers for the first n natural numbers. The integer n is to be entered by the user. [15] Question 5 A cloth showroom has announced the following festival discounts on the purchase of items, based on the total cost of the items purchased:- Total cost Discount (in Percentage) Total cost Discount (in Percentage) Less than Rs. 2000 5% Rs. 2001 to Rs. 5000 25% Rs. 5001 to Rs. l0000 35% Above Rs. 10000 50% Write a program to input the total cost and to compute and display the amount to be paid by the customer after availing the discount. [15]

Question 6 Consider the following statement:"January 26 is celebrated as the Republic Day of India". Write a program to change 26 to 15, January to August, Republic to Independence and finally print "August 15 is celebrated as the Independence Day of India". [15] Question 7 Write a program that outputs the results of the following evaluations based on the number entered by the user. (i) Natural logarithm of the number (ii) Absolute value of the number (iii) Square root of the number (iv)Random numbers between 0 and 1. [15] Question 8 The marks obtained by 50 students in a subject are tabulated as follows:- Name Marks Write a program to input the names and the marks of the students in the subject. Calculate and display:i. The subject average marks ( subject average marks = subject total / 50 ) ii. The highest mark in the subject and the name of the student. iii. The maximum marks in the subject are 100) [15] Question 9 Write a program to accept 15 integers from the keyboard, assuming that no integer entered is a zero. Perform selection sort on the integers and then print them in ascending order. [15 Question 4 Define a class salary described as below:Data Members : Name, Address, Phone, Subject Specialization, Monthly Salary, Income Tax. Member methods : (i) To accept the details of a teacher including the monthly salary. (ii) To display the details of the teacher. (iii) To compute the annual Income Tax as 5% of the annual salary above Rs.1,75,000/-. Write a main method to create object of a class and call the above member method. [15] Question 5 Write a program to compute and display the sum of the following series:- [15] 1+ 2 1 2 + 1 + 2+ 3 1 2 3 +.......+ 1 + 2 + 3 + 4....n 1 2 3 4....n Question 6 Write a program to initialize the given data in an array and find the minimum and maximum values along with the sum of the given elements. Numbers : 2 5 4 l 3 Output : Minimum value : l Maximum value : 5 Sum of the elements : [15]

Question 7 Write a program to enter a sentence from the keyboard and count the number of times a particular word occurs in it. Display the frequency of the search word. Example: INPUT: Enter a sentence : the quick brown fox jumps over the lazy dog. Enter a word to be searched : the OUTPUT: Searched word occurs : 2 times. [15] Question 8 Using a switch statement, write a menu driven program to convert a given temperature from Fahrenheit to Celsius and vice versa. For an incorrect choice, an appropriate error message should be displayed. [15] (HINT : C = 5 9 (F 32) and F = 1.8 C + 32 Question 9 Write a program using a method Palin( ), to check whether a string is a Palindrome or not. A Palindrome is a string that reads the same from left to right and vice versa. E.g. MADAM, ARORA, ABBA, etc. [15] Question 4 Define a class Stock having the following description: Data members are name, quantity, rate Member functions are i) public void input( ) [To input name, quantity and rate] ii) public void sell(int x) [reduce x quantity from stock after checking stock] iii) public void add(int y) [ add y quantity into stock] iv) public void display( ) [display current stock position] [15]

Question 5

[15]

A man is paid the hourly rate (R) for the first 35 hours, he works in a week. There after, he is paid at 1.5 time that hourly rate (R) for the next 25 hours he works in a week, and at twice the hourly rate (R) for a further 10 hours in a week. He is not allowed to work for more than 70 hours in a week. Taking the number of hours worked (H) and the rate per hour (R) as inputs, the weekly wages (W) are to be calculated and printed. Write a JAVA program for the above situation and print the weekly wages.

Question 6 Write a program to input a number and display sum of first and last digit only. e.g. input num = 3459 num = 568 output output sum = 3 + 9 = 12 sum = 5 + 8 = 13

[15]

Question 7

[15]

Write a program to input value of x and n. Display sum of following series

Question 8 Write a program to input a name and display name in following format. e.g. Input name = Amit Kumar Verma name = Ajay Yadav Output Verma, A.K. Output Yadav, A.

[15]

Question 9

[15]

Write a program to input a string. Convert all vowels in lower case and all consonant in Upper case. (A string may be upper, lower and special characters) e.g. Input st = WELCome TO School

Output WeLCoMe To SCHooL

Question 4

[15]

The standard form of quadratic equation is given by: ax2 + bx + c = 0, where d = b2 4*a*c , is known as discriminate which determines the nature of the roots of the equation accordingly : If d >= 0 If d < 0 Roots are real Roots are imaginary

WAP in Java to determine the roots of a quadratic equation (if d > 0) taking a, b, c as input, otherwise roots are Imaginary. Where roots are given by the formula: r1 = , r2 =

Question 5

[15]

In an election, out of 1249 voter in a booth, only 861 voters used their franchise correctly. If five candidates are contesting, write a program in Java to find: (i) (ii) The number of invalid and valid votes and The percentage of the valid votes received by each candidate.

Question 6 Write a program to input a number and display sum of first and last digit only. e.g. input num = 3459 num = 568 output output sum = 3 + 9 = 12 sum = 5 + 8 = 13

[15]

Question 7 Write a program to display following series 123454321 1234 123 12 1 4321 321 21 1

[15]

Question 8

[15]

Write a program to input a no and check no is PalPrime no or not. (PalPrime is a no which Palindrome as well as Prime) e.g. 131

You might also like