Given the number of calls of a user the task is to calculate total bill based on given tariff.
- From 1 to 50 calls 3 ₹/call
- From 51 to 150 calls 2.5 ₹/call
- From 151 to 350 calls 2 ₹/call
- From 351 to 750 calls 1.5 ₹/call
- More than 750 calls 1 ₹/call
Java
import java.util.*;
public class TelephoneBill
{
public static void main(String args[])
{
int n=0;
double amount=0.0;
Scanner sc=new Scanner(System.in);
System.out.print("Number of Calls: ");
n=sc.nextInt();
if(n>0&&n<=50)
{
amount=n*3;
}
else if(n>50&&n<=150)
{
amount=n*2.5;
}
else if(n>150&&n<=350)
{
amount=n*2;
}
else if(n>350&&n<=750)
{
amount=n*1.5;
}
else if(n>750)
{
amount=n*1;
}
else
{
System.out.println("Number of calls can't be non zero or negative");
}
System.out.println("Payable Amount: Rs "+amount);
}
}Java