Uploaded by Feras Osama Abu Zayed

EX 1 + EX 2

advertisement
1. Convert 999999 to dd : hh : mm : ss
dd – days, hh – hours, mm – minutes , ss – seconds
int theNumber = 999999;
int dd = theNumber / 1440;
int hh = theNumber/3600;
int m = theNumber%3600;
int mm = m/60;
int ss = theNumber%60;
System.out.println( dd + "\n" + hh + "\n" + mm + "\n" + ss);
2. Calculate the height of a cylinder, consider the following equation
𝒗𝒐𝒍𝒖𝒎𝒆
𝒉𝒆𝒊𝒈𝒉𝒕 =
𝝅 𝒓𝒂𝒅𝒊𝒖𝒔𝟐
Take volume and radius from keyboard. Then print the height on
the console.
Scanner keyboard = new Scanner (System.in);
System.out.println("Enter the volume");
double volume = keyboard.nextDouble();
System.out.println("Enter the radius");
double radius = keyboard.nextDouble();
double height = volume / (3.14*(radius*radius));
System.out.println("the height =" + height);
Download