Write a program in java using Scanner class to calculate the telephone bills as per the instructions below
First 100 calls for Rs 1 per call
Additional 50 calls Rs 1.50 per calls and for more than 150 Rs 2 per call
Answers
Explanation:
Self explanatory program given below with comments.
Explanation:
import java.util.Scanner;
public class PhoneBill
{
int calls;
double money;
/* constructor function over loaded to take the number of input calls */
public PhoneBill(){
Scanner s=new Scanner(System.in);
System.out.println(“Enter the number of calls made by customer”);
/* Calls variable holds the number of calls entered */
calls = s.nextInt();
}
/* Method definition of billing */
public double billing()
{
if (calls <= 100) /* Rs. 100 for first 100 calls */
money = 100;
else if (calls > 100) && (calls <= 150)
/* Additional 50 calls also charged at Rs.1 per call */
money = 1*(calls);
else if (calls > 150)
/* After 150 calls , charge Rs. 1.50 per call */
money = 150 + (calls-150)* 1.50;
return money;
}
public static void main(String[] args) {
PhoneBill p = new PhoneBill();
System.out.println(“Bill generated = ”+ p.billing());
}
}
I hope this may help you..
plz mark it as BRAINLIST..
THANKS...