Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
11 views

10th_Assignment 06_Program

The document outlines a programming assignment consisting of ten questions that require the design of various classes and methods in Java. Tasks include creating a cab service billing system, method overloading for counting digit frequency, a menu-driven program for mathematical operations, and various array manipulations. Additional requirements involve string analysis, sorting characters, and checking for lead numbers based on digit sums.

Uploaded by

Iamperoplayer 21
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views

10th_Assignment 06_Program

The document outlines a programming assignment consisting of ten questions that require the design of various classes and methods in Java. Tasks include creating a cab service billing system, method overloading for counting digit frequency, a menu-driven program for mathematical operations, and various array manipulations. Additional requirements involve string analysis, sorting characters, and checking for lead numbers based on digit sums.

Uploaded by

Iamperoplayer 21
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

ASSIGNMENT NO 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

Design a class CabService with the following description:


Member variables /data members:
String car_type - To store the type of car (AC or NON AC)
double km - To store the kilometer travelled
double bill - To calculate and store the bill amount

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.

Q2) Design a class to overload a method Number( ) as follows:


(i) void Number (int num , int d)- To count and display the frequency of a digit in a number.
Example:
num = 2565685
d=5
Frequency of digit 5 = 3

(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.

Q8) Define a class to overload the function print as follows:


void print() to print the following format
1111
2222
3333
4444
5555
void print(int n) To check whether the number is a lead number. A lead number is the one
whose sum of even digits are equal to sum of odd digits.
e.g. 3669
odd digits sum = 3 + 9 = 12
even digits sum = 6 + 6 = 12
3669 is a lead number.
Q9) 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”.

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

You might also like