Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
2 views

JavaLabassign3

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
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

JavaLabassign3

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
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Name: B.

Latha Sagar

RegNo: 12204652

Roll No: 42

Section: D2212

Course Code: CAP680

Codehs link:

https://codehs.com/sandbox/id/new-sandbox-program-1XHLVK

source code:

package assignment;

import java.util.*;

public class Time

float hours;

float mins;

float secs;

static float totaltime2;

void callDur()

System.out.println("enter call duration :");

Scanner sc=new Scanner(System.in);

System.out.println("enter starting time duration :");

int callStart=sc.nextInt();
System.out.println("enter ending time duration :");

int callEnd=sc.nextInt();

int totalTime=callEnd-callStart;

totaltime2=totalTime*60;

System.out.println("Total time is :"+totalTime);

float startTime=sc.nextInt();

float endTime=sc.nextInt();

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

float callRate=totaltime2*9;

System.out.println("call rate for 9-11 is :"+callRate);

else

float callRate = totalTime*10;

System.out.println("call rate for other then 9-11 is :"+callRate);

public static void main(String[]args)

Time t=new Time();

t.callDur();

Hours h=new Hours();

h.hourCon();
Min m=new Min();

m.minCon();

sec s=new sec();

s.secCon();

class Hours extends Time

public void hourCon()

hours= totaltime2/60;

System.out.println("totalhour is :"+hours);

class Min extends Time

public void minCon()

mins=totaltime2*60;

System.out.println("totalminsis :"+mins);

class sec extends Time

public void secCon()

{
secs= (totaltime2*60*60);

System.out.println("totalsecs :"+secs);

Output:

You might also like