0% found this document useful (0 votes)
3 views4 pages

Java Call Duration Calculator Code

The document contains a Java program that calculates the duration and cost of a phone call based on user input for start and end times. It includes classes for handling time in hours, minutes, and seconds, and calculates call rates for specific time intervals. The program prompts the user for input and displays the total duration and cost of the call.

Uploaded by

NIKLAUS
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views4 pages

Java Call Duration Calculator Code

The document contains a Java program that calculates the duration and cost of a phone call based on user input for start and end times. It includes classes for handling time in hours, minutes, and seconds, and calculates call rates for specific time intervals. The program prompts the user for input and displays the total duration and cost of the call.

Uploaded by

NIKLAUS
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Name: B.

Latha Sagar

RegNo: 12204652

Roll No: 42

Section: D2212

Course Code: CAP680

Codehs link:

[Link]

source code:

package assignment;

import [Link].*;

public class Time

float hours;

float mins;

float secs;

static float totaltime2;

void callDur()

[Link]("enter call duration :");

Scanner sc=new Scanner([Link]);

[Link]("enter starting time duration :");

int callStart=[Link]();
[Link]("enter ending time duration :");

int callEnd=[Link]();

int totalTime=callEnd-callStart;

totaltime2=totalTime*60;

[Link]("Total time is :"+totalTime);

float startTime=[Link]();

float endTime=[Link]();

if(startTime==9 && endTime==11)

float callRate=totaltime2*9;

[Link]("call rate for 9-11 is :"+callRate);

else

float callRate = totalTime*10;

[Link]("call rate for other then 9-11 is :"+callRate);

public static void main(String[]args)

Time t=new Time();

[Link]();

Hours h=new Hours();

[Link]();
Min m=new Min();

[Link]();

sec s=new sec();

[Link]();

class Hours extends Time

public void hourCon()

hours= totaltime2/60;

[Link]("totalhour is :"+hours);

class Min extends Time

public void minCon()

mins=totaltime2*60;

[Link]("totalminsis :"+mins);

class sec extends Time

public void secCon()

{
secs= (totaltime2*60*60);

[Link]("totalsecs :"+secs);

Output:

You might also like