0% found this document useful (0 votes)
4 views

Java Question

Uploaded by

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

Java Question

Uploaded by

Indranil Pathak
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Ikon computer education & training institute

Marks: 6*8=48 subject: Java


_____________________________________________________________

1. Design a class Railway Ticket with the following description:


Instance variables / data members:
String name: to store the name of the customer.
String coach: to store the type of coach customer wants to travel.
long mobno: to store customer’s mobile number.
int amt: to store basic amount of ticket.
int totalamt: to store the amount to be paid after updating the original amount.
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 a customer such as name, coach, total amount and
mobile number.
Write a main() method to create an object of the class and call the above methods.

2. Write a program to input a number and check and print whether it is a Pronic number or
not. Pronic number is the number which is the product of two consecutive integers.
Examples:
12 = 3 × 4
20 = 4 × 5
42 = 6 × 7

3. Write a program in Java to accept a string in lowercase and change the first letter of every
word to uppercase. Display the new string.
Sample INPUT: we are in cyber world
Sample OUTPUT: We Are In Cyber World

4. Design a class to overload a function volume() as follows:


(i) double volume(double r) – with radius ‘r’ as an argument, returns the volume of sphere
using the formula:
v = 4 / 3 × 22 / 7 × r3
(ii)double volume(double h, double r) – with height ‘h’ and radius ‘r’ as the arguments,
returns the volume of a cylinder using the formula:
v = 22 / 7 × r2 × h
(iii) double volume(double l, double b, double h) – with length ‘l’, breadth ‘b’ and height ‘h’ as
the arguments, returns the volume of a cuboid using the formula:
v=l×b×h

5. Write a program to accept name and total marks of N number of students in two single
subscripted arrays namely, name[ ] and totalmarks[ ].

Calculate and print:


(i) The average of the total marks obtained by N number of students.
[average = (sum of total marks of all the students) / N]
(ii) Deviation of each student’s total marks with the average.
[deviation = total marks of a student – average]

6. A special two-digit number is such that when the sum of its digits is added to the product
of its digits, the result is equal to original number
Example : 59
5+9 = 14
5*9 = 45
45+14 = 59 Therefore , 59 is a special two digit number
Write a program in java to check whether a number is special two-digit number or not

You might also like