10th_Assignment 06_Program
10th_Assignment 06_Program
Q1) A private Cab service company provides service within the city at the following rates:
AC CAR NON AC CAR
UPTO 5 KM ₹ 150 /- ₹ 120 /-
BEYOND 5 KM ₹ 10/-PER KM ₹ 08/- PER KM
Member methods :
CabService()- Default constructor to initialize data members.String data members to '' '' and
double data members to 0.0.
void accept ()- To accept car_type and km (using Scanner class only).
void calculate () - To calculate the bill as per the rules given above.
void display() - To display the bill as per the following format
CAR TYPE:
KILOMETER TRAVELLED:
TOTAL BILL:
Create an object of the class in the main method and invoke the member methods.
(ii)void Number (int n1)-To find and display the sum of even digits of a number.
Example:
n1 = 29865
Sum of even digits = 16
Write a main method to create an object and invoke the above methods.
Q3) Write a menu driven program to perform the following operations as per user’s choice:
(i) To print the value of c=a2 +2ab, where a varies from 1.0 to 20.0 with increment of 2.0 and
b=3.0 is a constant.
(ii) To display the following pattern using for loop:
A
AB
ABC
ABCD
ABCDE
Display proper message for an invalid choice.
Q4) Define a class to accept values in integer array of size 10. Find sum of one digit number
and sum of two digit numbers entered. Display them separately.
Example:
Input: a[ ] = {2, 12, 4, 9, 18, 25, 3, 32, 20, 1}
Output:
Sum of one digit numbers : 2 + 4 + 9 + 3 + 1 = 19
Sum of two digit numbers : 12 + 18 + 25 + 32 + 20 = 107
Q5) Define a class to accept values into an array of double data type of size 20. Accept a
double value from user and search in the array using linear search method. If value is found
display message “Found” with its position where it is present in the array. Otherwise display
message “not found”.
Q6) Define a class to accept a String and print the number of digits, alphabets and special
characters in the string.
Example:
Input:
S = “KAPILDEV@83”
Output:
Number of digits – 2
Number of Alphabets – 8
Number of Special characters – 1
Q7) Define a class to accept 10 characters from a user. Using bubble sort technique arrange
them in ascending order. Display the sorted array and original array.
Q10) Define a class to accept values in integer array of size 10. Find sum of one digit number
and sum of two digit numbers entered. Display them separately.
Example:
Input:
a[ ] = {2, 12, 4, 9, 18, 25, 3, 32, 20, 1}
Output:
Sum of one digit numbers : 2 + 4 + 9 + 3 + 1 = 19
Sum of two digit numbers : 12 + 18 + 25 + 32 + 20 = 107