0% found this document useful (0 votes)
2 views

java program

The document contains Java code examples demonstrating the calculation of temperature conversion from Fahrenheit to Celsius and the calculation of monthly telephone charges. The telephone charges include a fixed amount and variable charges based on the number of calls made, with different rates applied to different call ranges. The final output of the telephone charges program is the total bill calculated based on the number of calls.

Uploaded by

tushikasahu5
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

java program

The document contains Java code examples demonstrating the calculation of temperature conversion from Fahrenheit to Celsius and the calculation of monthly telephone charges. The telephone charges include a fixed amount and variable charges based on the number of calls made, with different rates applied to different call ranges. The final output of the telephone charges program is the total bill calculated based on the number of calls.

Uploaded by

tushikasahu5
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

class Demo

{
public static void main(string args[])
{
System.out.Println("Hello")
}
}

class Main
{
public static void main(String args[])
{
double fahrenheit=98.0;
double celsius = (fahrenheit - 32) * 5 / 9;
System.out.println(celsius);
}
}

WRITE A PROGRAM TO CALCULATE MONTHLY TELEPHONE CHARGES FOR A PERSON CHARGES


CONSISTES OF FIX AMOUNT 250... AND VARIABLE CHARGES BASED ON NUMBER CALL AND
VARIABLE CHARGES CALCULATE AS FOLLOW
0.50 FROM EACH 1ST 100 CALL... 0.60 FOR NEXT 100 CALL... 0.75 FOR REMAINING
CALCULATE TOTAL BILL

class Main
{
public static void main(String args[])
{
int fixed_amt =250;
int calls = 450;
double hcall = 0.50;
double scall = 0.60;
double rcall = 0.75;
double amount = 0.0;
double total_amount;
if (calls <= 100)
amount = calls*hcall;
else if (calls <= 200)
amount = (100*hcall) + (calls-100)*scall;
else
amount = (100*hcall) + (100*scall)+ (calls-200)*rcall;
total_amount=amount+fixed_amt;
System.out.println(total_amount);
}
}

You might also like