Computer Science, asked by jyotirmaykrjha, 11 months ago

Correct will get BRAINLIEST...

Write a program in JAVA to calculate the telephone bill as per the following data:

For 100 calls 0 paise per calls
For the next 100 calls 90 paise per calls
For the next 200 calls 80 paise per calls
For more than 400 calls 70 paise per calls

Answers

Answered by imalfaizkhan
20

Answer:

import java.util.*;

class Telephone

{

int prv, pre,call;

String name;

double amt,total;

void input()

{

Scanner sc=new Scanner(System.in);

System.out.println(“Enter the previous meter reading:”);

prv=sc.nextInt();

System.out.println(“Enter the present meter reading:”);

pre=sc.nextInt();

ystem.out.println(“Enter the name:”);

name=sc.nextLine();

}

void cal()

{

call=pre-prv;

if(call<=100)

amt=0;

else if(call>100 && call<=200)

amt=0*100+(call-100)*0.90;

else if(call>200 && call<=400)

amt=0*100+100*0.90+(call-200)*0.80;

else

amt=0*100+100*0.90+200*0.80+(call-400)*0.70;

total=amt+180;

}

void display()

{

System.out.println(“Name\t\tCalls Made\t\tAmount\t\tTotal Amount”);

System.out.println(name+“\t\t”+call+“\t\t”+amt+“\t\t”+total);

}

public static void main(String args[])

{

Telephone ob=new Telephone();

ob.input();

ob.cal();

ob.display();

}

}

Similar questions