File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ /* You are in charge of the cake for a child's birthday. You have decided the cake will have one candle
2+ for each year of their total age. They will only be able to blow out the tallest of the candles.
3+ Count how many candles are tallest. A Program to input candle heights and print the total number
4+ of tallest candles present on the cake*/
15import java .io .*;
26import java .util .Arrays ;
37class birthday
48 {
59 int candle_count (int [] a , int x ) //a method to sort and calculate the number of candles.
610 {
7- Arrays .sort (a ); //to sort the elements in asscending order
11+ Arrays .sort (a ); //to sort the elements in ascending order
812 int c =0 ;
913 int lst = a [x -1 ];
1014 for (int i =x -1 ;i >=0 ;i --)
@@ -24,7 +28,7 @@ public static void main() throws IOException
2428 for (int i =0 ;i <ln ;i ++)
2529 {
2630 cdl [i ]=Integer .parseInt (br .readLine ());
27- if (cdl [i ]==0 )
31+ if (cdl [i ]==0 ) //this will ensure that the input is not 0
2832 i =i -1 ;
2933 }
3034 birthday obj = new birthday ();
You can’t perform that action at this time.
0 commit comments