Use app×
Join Bloom Tuition
One on One Online Tuition
JEE MAIN 2025 Foundation Course
NEET 2025 Foundation Course
CLASS 12 FOUNDATION COURSE
CLASS 10 FOUNDATION COURSE
CLASS 9 FOUNDATION COURSE
CLASS 8 FOUNDATION COURSE
0 votes
5.2k views
in Computer by (49.8k points)
closed by

A class SwapSort has been defined to perform string related operations on a word input. Some of the members of the class are as follows: 

Class name: SwapSort 

Data members/instance variables: 

wrd: to store a word 

len: integer to store the length of the word 

swapwrd: to store the swapped word 

sortwrd: to store the sorted word 

Member functions/methods: 

SwapSort(): default constructor to initialize data members with legal initial values 

void readword(): to accept a word in UPPER CASE 

void swapchar(): to interchange/swap the first and last characters of the word in ‘wrd’ and stores the new word in ‘swapwrd’ 

void sortword(): sorts the characters of the original word in alphabetical order and stores it in ‘sortwrd’ 

void display(): displays the original word, swapped word and the sorted word Specify the class SwapSort, giving the details of the constructor(), void readword(), void swapchar(), void sortword() and void display(). Define the main() function to create an object and call the functions accordingly to enable the task.

1 Answer

+1 vote
by (48.9k points)
selected by
 
Best answer

import java.io.*; 

class Product 

String name; 

int code; 

double amount; 

Product(String n, int c, double p) { 

name = n; 

code = c; 

amount = p; 

void show() { 

System.out.println("Name is :"+ name); 

System.out.println("Code is :" + code); 

System.out.println("Total Sale Amount:" + amount); 

class Sales extends Product { 

int day; 

double tax; 

double totamt; 

double fine = 0.0; 

Sales(String n, int c, double p, int d) { 

super(n, c, p); 

day = d; 

void compute() 

if(day < 30){ tax = 12.4 * amount /100; totamt = amount + tax; 

if(day > 30) { 

tax= 12.4 * amount /100; 

fine = 2.5 * amount /100; 

totamt = amount + tax + fine; 

} void show () { 

show(); 

System.out.println("Total amount to be paid::"+ totamt); 

}

Welcome to Sarthaks eConnect: A unique platform where students can interact with teachers/experts/students to get solutions to their queries. Students (upto class 10+2) preparing for All Government Exams, CBSE Board Exam, ICSE Board Exam, State Board Exam, JEE (Mains+Advance) and NEET can ask questions from any subject and get quick answers by subject teachers/ experts/mentors/students.

Categories

...