CodeGym
CodeGym University
Java FullStack
Learning
Courses
Tasks
Surveys & Quizzes
Games
Help
Schedule
Community
Users
Forum
Chat
Articles
Success stories
Activity
Reviews
Subscriptions
Light theme
Question
  • Reviews
  • About us
Start
Start learning
Start learning now
  • All questions
CodeGym/Help with Java Tasks/can not figure it out. Any help with n?
Willard Roseberry
Level 11
Brigham City
  • 12/2/19
  • 1631views
  • 0comments

can not figure it out. Any help with n?

Question about the task Task about algorithms
Java Syntax,  Level 5,  Lesson 12
Resolved


Write a program that:
1. reads a number N (must be greater than 0) from the console
2. reads N numbers from the console
3. Displays the maximum of the N entered numbers.

Requirements:
  • The program should read the numbers from the keyboard.
  • The program must display a number on the screen.
  • The class must have a public static void main method.
  • Don't add new methods to the Solution class.
  • The program should display the maximum of the N entered numbers.
  • The program should not display anything if N is less than or equal to 0.
package com.codegym.task.task05.task0532; import java.io.*; import java.util.Scanner; /* Task about algorithms */ public class Solution { public static void main(String[] args) throws Exception { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); int maximum = Integer.MIN_VALUE; Scanner sc = new Scanner(System.in); int n = sc.nextInt(); for (int j = 0; j < n; j++){ // maximum = n; if (n > maximum){ maximum = n; } //System.out.println(maximum); // System.out.println(maximum); } System.out.println(maximum); //write your code here } }
0
Comments
  • Popular
  • New
  • Old
You must be signed in to leave a comment
This page doesn't have any comments yet
Learn
  • Registration
  • Java Course
  • Help with Tasks
  • Pricing
  • Java Syntax
Community
  • Users
  • Articles
  • Forum
  • Chat
  • Success Stories
  • Activity
  • Affiliate Program
Company
  • About us
  • Contacts
  • Reviews
  • Press Room
  • CodeGym for EDU
  • FAQ
  • Support
CodeGym CodeGym is an online course for learning Java programming from scratch. This course is a perfect way to master Java for beginners. It contains 1200+ tasks with instant verification and an essential scope of Java fundamentals theory. To help you succeed in education, we’ve implemented a set of motivational features: quizzes, coding projects, content about efficient learning, and a Java developer’s career.
Follow us
Interface language
English
Deutsch Español हिन्दी Français Português Polski বাংলা 简体中文 मराठी தமிழ் Italiano Bahasa Indonesia 繁體中文 Nederlands 日本語 한국어 Bulgarian Danish Hungarian Basa Jawa Malay Norwegian Romanian Swedish Telugu Thai Українська Filipino Turkish Azərbaycan Русский Vietnamese
Programmers Are Made, Not Born © 2026 CodeGym
MastercardVisa
Programmers Are Made, Not Born © 2026 CodeGym