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
10.4k views
in Computer by (49.8k points)
closed by

Design a class name ShowRoom with the following description :

Instance variables/ Data members : 

String name – To store the name of the customer 

long mobno – To store the mobile number of the customer

double cost – To store the cost of the items purchased 

double dis – To store the discount amount 

double amount – To store the amount to be paid after discount

Member methods: – 

ShowRoom() – default constructor to initialize data members 

void input() – To input customer name, mobile number, cost 

void calculate() – To calculate discount on the cost of purchased items, based on 

following criteria

Cost Discount (in percentage)
Less than or equal to ₹ 10000 5%
More than ₹ 10000 and less than or equal to ₹ 20000 10%
More than ₹ 20000 and less than or equal to ₹ 35000 15%
More than ₹ 35000 20%

 

1 Answer

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

Solution. 

import java.io.*; 

import java.util.*; 

class ShowRoom 

String name; 

long mobno; 

double cost; 

double dis; 

double amount; 

ShowRoom( ) 

name = ” “; 

mobno =0;

cost = 0; 

dis = 0; 

amount = 0; 

void input( ) 

Scanner sc = new Scanner(System.in); 

System.out.println(“EnterName:”); 

name = sc.nextLine( ); 

System.out.println(“Enter Mobile number:”); 

mobno = sc.nextLong( ); 

System.out.println(“Enter cost:”); 

cost = sc.nextDouble( ); 

}

void calculate( ) 

if (cost 10000 && cost < = 20000)

dis = cost* 10/100; 

amount cost – dis; 

else 

if (cost > 20000 && cost < = 35000)

{ dis = cost* 15/100; 

amount = cost – dis; 

else 

if (cost > 35000)

dis = cost*20/100; 

amount = cost – dis; 

}

void display( ) 

System.out.println(“Name::” +name); 

System.out.println(“Mobile No.::” +mobno); 

System.out.println(“Amount::” +amount); 

public static void main(String args( )) 

ShowRoom ob = new ShowRoom( ); 

ob.input( ); 

ob.calculate( ); 

ob.display( ); 

}

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

...