The telephone department wishes to compute monthly telephone bills

The telephone department wishes to compute monthly telephone bills


The telephone department wishes to compute monthly telephone bills for its customers on the basis of call made:      

 Number of calls                                         Rate                                    

First 80 calls                                      Rs.2.50 per call                                    

Next 80 calls                                     60 paisa per call                                    

Next 160 calls                                   50 paisa per call                                    

Any call above 280 calls                 40 paisa per call                       

Write a JAVA program to input the number of calls and compute the total bill amount.


import java.util.*;
class Telephonebill 
{
public static  void main()                                                                                        
{  
Scanner Sc=new Scanner(System.in);                                                                                       System.out.println(“Enter no of calls made ”);   
double c=Sc.nextDouble();double a=0;
if(c>=80)                                                                                                           
{
a=2.50*c;
}                                                                                                                                                                                    else if(c>=80&&c<=160)                                                  
{  
a=(80*2.50)+((c-180*0.60);
}                                                                                                                                                  
else if(c>=160&&c<=280) 
{  
a=(80*2.50)+(80*0.60)+(( c-160)*0.50);
}                          
else if(a>=280)                                                                                                                             

a=(80*2.50)+(80*0.60)+(120*0.50)+((c-280)*0.40;
}                    
{
System.out.println(“Total number of calls made is “+c);
}                                                                                        
{
 System.out.println(“Bill amount is “+a);
}   }  }


Output: Enter the no. of calls made  200  
Total number of calls made is 200
Bill amount is 264

-------------------------------------------------------------------------------------------------------------

Just copy paste the code into the class file of Bluej compiler. Change the class name according to your's. 

Thanks for visting Programming in JAVA

Happy Coding !!


3 comments:

Powered by Blogger.