COMPUTER X 1st Term
COMPUTER X 1st Term
Question 3: |15|
Design aclass RailwayTicket with following description:
Instance variables/data members:
String nameTo store the name of thecustomer.
String coach To store the type of coach customer wants to travel.
long mobno -To store customer's mobile number.
int amtTo store basic amount of ticket.
int totalamt - To store the amount to be paid after updating the original amount.
Member methods:
void accept() -To take input for name, coach, mobile number and amount.
void update() - To update the amount as per the coach
selected (extra amount to be added in the amount as
follows)
Type of Coaches Amount
First AC 700
Second AC 500
Third AC 250
sleeper None
void display() -To display all details of acustomer such as
name,
Write a main method to create an object of the class and call the coach, total amount and mobile number.
above member methods.
Question 4:
The International Standard Book Number (ISBN) [15]
is a unique numeric book identifier which is
every book. The ISBN is based upon a 10-digit code. printed on
The ISBN is legal if:
1xdigitl +2 xdigit2 +3 x digit3 + 4 x digit4 +5 x digits + 6 x digit6 + 7 x
+ 10x digit10 is divisible by 11. digit7 +8 x digit8 +9x digit9
Example:
For an ISBN 1401601499
Sum = 1x1+2 x 4 +3x 0+4 x 1+ 5 x6+ 6x 0+7 x |+8 x 4+9 x9 +10 x9 =253 which is
divisible
by 11.
Write a program to:
1 Input the ISBN code as a 10-digit integer.
2 If the ISBN is not a 10-digit integer, output the message "Illegal ISBN" and terminate the program.
3 If the number is divisible by 11, output the message "Legal ISBN". Ifthe sum is not divisible by l1,
output the message "Illegal ISBN".
Question5: |15]
Write a menu driven program to perform the following operations as per the user's choice:
1. To print the value of ca'+2ab, where a varies from 1.0 to 2,0 and b=3.0is a
with increment of
20.0
constant.
2. To display the following pattem using for loop
A
AB
ABC
ABCD
ABCDE
Display proper message for an invalid choice.
|15]
Question 6:
and special characters). Perform
(including digits
Write a program in Java to accept astring in a mixed case
the following tasks as per the user's choice:
1. Count and display the number of vowels.
2. Count and display the digit.
characters, excluding white spaces.
3. Count and display the number of special
Sample input: 15 August is celebrated as "Independence Day"
Sample output:
Number of vowels = 15
Number of digits =2
Number of special characters -2.
[15]
Question 7:
display() as follows:
Define a class to overload the method
using nested loop
void display(): Toprint the following format
12121
12121
user)
12121 (input the number of row from division of and n ifm isgreater thann,
m
otherwise
the quotient of the
void display(int n,int m):To print
n and thrice m
print the sum of twice
b,double c): to print the value of z, where z=p*q
double display(double a,double
p-(atb)/c and q=a+btc
[15]
number is
Question 8:
and check whether the number is an Adam number or not. A
Write a program to input a number square of a number is equal to the
square of the reverse if the
Number if the reverse of the
called an Adam
number. value.]
number then just print its absolute
[If the user enters a negative
Example: 12
reverse is 441
Square of 12=144 and its
2|=441
Reverse of 12-21 and square of
Thus, 12 is an adam number.