Hi can someone explain how the output works. I really dont understand what should be the output for this. what I did is that I first i tried to let the user input just one integer number and get the maximum of the single digit number like:
the user input 1234 then the output is 4
the second one I used loops to let the user input as many until it stops when its equal to or lower than zero.
help me please
package com.codegym.task.task05.task0532;
import java.io.*;
/*
Task about algorithms
*/
public class Solution {
public static void main(String[] args) throws Exception {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
int maximum = 0;
//write your code here
int temp;
while((temp = Integer.parseInt(reader.readLine()))>0){
if(temp>maximum){
maximum = temp;
}
}
System.out.println(maximum);
}
}