plzz do program no. 18 in java
Attachments:
jiya6666:
how much u did?
Answers
Answered by
8
package jiyaa;
public class Discount {
public String name;
public String category;
public int days;
public void print_Bill()
{ float money = 0;
String cate=" ";
if(this.category=="S")
{
money=2500;
cate="Semi-Delux";
}
if(this.category=="D")
{
money=3500;
cate="Delux";
}
if(this.category=="SD")
{
money=5000;
cate="Super-Delux";
}
if(this.days<=3)
{
money=(money*90)/100;
}
if(this.days>3 && this.days<=5)
{
money=(money*85)/100;
}
if(this.days>5 && this.days<=10)
{
money=(money*80)/100;
}
if(this.days>10)
{
money=(money*70)/100;
}
System.out.println(this.name +" you hav to pay rs "+money+" for categoery "+cate+" for staying "+this.days+" days.");
}
public static void main(String[] args) {
Discount ob1=new Discount("bk","S" , 10);
Discount ob2=new Discount("bk1","SD" , 5);
Discount ob3=new Discount("bk2","D" , 2);
ob1.print_Bill();
ob2.print_Bill();
ob3.print_Bill();
}
public Discount(String name, String category, int days) {
super();
this.name = name;
this.category = category;
this.days = days;
}
}
public class Discount {
public String name;
public String category;
public int days;
public void print_Bill()
{ float money = 0;
String cate=" ";
if(this.category=="S")
{
money=2500;
cate="Semi-Delux";
}
if(this.category=="D")
{
money=3500;
cate="Delux";
}
if(this.category=="SD")
{
money=5000;
cate="Super-Delux";
}
if(this.days<=3)
{
money=(money*90)/100;
}
if(this.days>3 && this.days<=5)
{
money=(money*85)/100;
}
if(this.days>5 && this.days<=10)
{
money=(money*80)/100;
}
if(this.days>10)
{
money=(money*70)/100;
}
System.out.println(this.name +" you hav to pay rs "+money+" for categoery "+cate+" for staying "+this.days+" days.");
}
public static void main(String[] args) {
Discount ob1=new Discount("bk","S" , 10);
Discount ob2=new Discount("bk1","SD" , 5);
Discount ob3=new Discount("bk2","D" , 2);
ob1.print_Bill();
ob2.print_Bill();
ob3.print_Bill();
}
public Discount(String name, String category, int days) {
super();
this.name = name;
this.category = category;
this.days = days;
}
}
Similar questions