Write a program to calculate the telephone bill ☎


import java.util.*;

public class telephonebill {
String id; int n; String name ; double amount;
void input()
{
Scanner sc = new Scanner (System.in);
System.out.println("ENTER YOUR NAME ");
name =sc.nextLine();
System.out.println("ENTER YOUR TELEPHONE id ");
id=sc.next();
System.out.println("ENTER THE NUMBERS OF CALL MADE ");
n=sc.nextInt();
}
void compute()
{
if(n<=100)
amount=500;
else if(n>100&&n<=200)
amount=500+9*(n-100); //this is just a random calculation
else if(n>200)
amount=800+9*(n-200); //this is just a random calculation
}
void display()
{
System.out.println("BILL : ");
System.out.println("NAME \t id \t Amount" );
System.out.println(name+"\t"+ id + "\t"+ amount);
}
public static void main(String[]args)
{
telephonebill ob = new telephonebill();
ob.input();
ob.compute();
ob.display();
}
}

FOR CODE : CLICK >> https://onecompiler.com/java/3ygpud8mv TO FIND OUTPUT

SUPPORT US >> https://onethoughttechnology.blogspot.com (OFFICIAL WEBSITE)