Question

# ShowRoom(): default constructor to initialize the data membersvoid input(): to input customer name, mobile number, costvoid calculate(): to calculate the discount on the cost of purchased items, based on the 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%

```
```

# Share code with your friends

Code

```				```
import java.util.Scanner;
public class ShowRoom
{
String name;
long mobno;
double cost,dis,amount;
/*default constructor*/
public ShowRoom()
{
name="";
mobno=0;
cost=0.0;
dis=0.0;
amount=0.0;
}
public void input()
{
Scanner sc = new Scanner(System.in);
name=sc.nextLine();
mobno=sc.nextLong();
System.out.print("Enter cost of item purchased: ");
cost=sc.nextDouble();
}
public void calculate()
{
if(cost<=10000)
{
dis = cost * 5/100;
amount = cost - dis;
}
else 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;
}
}
public void display()
{
System.out.println("Name of the customer: "+name);
System.out.println("Mobile number : "+mobno);
System.out.println("Amount to be paid after discount: "+amount);
}

public static void main(String[]args)
{
ShowRoom ob1 = new ShowRoom();
ob1.input();
ob1.calculate();
ob1.display();
}
}

```
```

## Coding Store

Sale ### Mastering String

50
Sale 150
Sale 200
Sale ### Mastering Recursion

50
Sale ### Mastering Numbers

50
Sale ### Mastering Matrix

50
Sale ### Mastering Array

50
Sale ### ISC QUESTION PAPERS WITH SOLUTION(PROGRAMMING ONLY)

50
Sale 50