Section A: 1. A) Why Is An Object Called An Instance of A Class?
Section A: 1. A) Why Is An Object Called An Instance of A Class?
Section A: 1. A) Why Is An Object Called An Instance of A Class?
Class name: ATransport
Member variables:
String name: to store the name of the customer.
int w: to store the weight of the parcel in kg.
int charge: to store the charge of the parcel.
Member functions:
void accept(): to accept the name of the customer, weight of the parcel from the user (using
Scanner class)
void calculate(): to calculate the charge as per the weight of the parcel as per the following
criteria:
WEIGHT IN KG CHARGE PER KG
Up to 10 kg Rs. 25 per kg
Example :-
Input: COMPUTER
Output:Unique String
Input: APPLICATIONS
Output: Not a Unique String
Question 8
Write a menu-driven program in Java for
Choice 1:capitalizes first letter of each word in a string .
Choice 2:capitalizes last letter of each word in a string
Question 9
Write a program that encodes a word into Piglatin. To translate a word into a Piglatin word,
convert the word into uppercase and then place the first vowel of the original word as the start of
the new word along with the remaining alphabets. The alphabets present before the vowel being
shifted towards the end followed by “AY”.
Sample Input (1) : London, Sample Output (1) : ONDONLAY
Sample Input (2) : Olympics, Sample Output (2) : OLYMPICSAY