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*/
51import java .io .*;
62import java .util .Arrays ;
73class birthday
84 {
95 int candle_count (int [] a , int x ) //a method to sort and calculate the number of candles.
106 {
11- Arrays .sort (a ); //to sort the elements in ascending order
7+ Arrays .sort (a ); //to sort the elements in asscending order
128 int c =0 ;
139 int lst = a [x -1 ];
1410 for (int i =x -1 ;i >=0 ;i --)
@@ -28,7 +24,7 @@ public static void main() throws IOException
2824 for (int i =0 ;i <ln ;i ++)
2925 {
3026 cdl [i ]=Integer .parseInt (br .readLine ());
31- if (cdl [i ]==0 ) //this will ensure that the input is not 0
27+ if (cdl [i ]==0 )
3228 i =i -1 ;
3329 }
3430 birthday obj = new birthday ();
You can’t perform that action at this time.
0 commit comments