हिंदी

The driver took a drive to a town 240 km at a speed of 60 km/h. Later in the evening, he drove back at 20 km/h less than the usual speed. Write a program to calculate: - Computer Applications

Advertisements
Advertisements

प्रश्न

The driver took a drive to a town 240 km at a speed of 60 km/h. Later in the evening, he drove back at 20 km/h less than the usual speed. Write a program to calculate: 

  1. the total time taken by the driver
  2. the average speed during the whole journey

[Hint: average speed = `"total distance"/"total time"`] 

संक्षेप में उत्तर

उत्तर

public class U5_Q5
{public static void main(String ag[]) 
{double dist = 240, t1, t2, tot, spd = 60, avgspeed;
t1 =dist / spd; // time = distance / speed 
t2 = dist / (spd − 20); // since speed was decreased by 20 km/h
tot = t1 + t2;
avgspeed = (2 * dist) / tot; // avg speed= total dist / total time
System.out.println("The total time for the journey: " + tot);
System.out.println("The average speed for the journey: " + avgspeed); 
}}
shaalaa.com
  क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
अध्याय 1.06: Input in Java - EXERCISES [पृष्ठ ६७]

APPEARS IN

अविचल Computer Applications [English] Class 10 ICSE
अध्याय 1.06 Input in Java
EXERCISES | Q V. 5. | पृष्ठ ६७
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×