CodeGym/Java Tasks/My young friend

My young friend

  • 2
  • Locked
In 3126, everyone knows about System.out.println() and uses it often. It's not just CodeGym students that begin to learn programming with this command. Even children do. Let's write a program that displays my friend's true birth year. He was born 8 years ago.
You can't complete this task, because you're not signed in.
Comments (85)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
27 June 2025, 16:47
int a = 3126; int b = 8; System.out.print(a-b);
Don Ricket
Level 2 , Serbia
15 January 2024, 11:21
public static void main(String[] args) { int year = 3126; int age = 8; System.out.println(year - age); } }
Daedalus Owner / Founder at BDI technologies
19 August 2023, 01:48
Easy two-line code:
int cYear = 3126, fYear = 8;
System.out.println(cYear - fYear);
AndyFrancisqo
Level 1 , United Kingdom
8 August 2023, 21:58
int currentYear = 3126; int friendAge = 8; int birthYear = currentYear - friendAge; System.out.println("My friend's birth year is " + birthYear);
Naif Al-Jaaidi (Nafmee)
Level 2 , Yemen
16 July 2023, 01:39
int currentYear = 3126; String birthYear = "My friend's birth year is " + (currentYear - 8); System.out.println(birthYear);
zam
Level 2 , Philippines
23 May 2023, 03:16
public class Solution { public static void main(String[] args) { int year = 3126; int ago = 8; System.out.println(year - ago); } }
Abrar Mirje
Level 1 , India
5 May 2023, 05:54
int currentDays = 3126; int age = currentDays - 8; System.out.println(age);
PRIYANKA DEWARE
Level 2 , Delhi, India
13 April 2023, 17:03
int a = 3126; int b = a - 8 ; System.out.println("my friends birth year."); System.out.println(b);
Nomophobic Girl
Level 2 , CodeGym University in India, India
11 March 2023, 16:12
And the answer is... System.out.print("my friends birth year"); System.out.println(3118);
Daedalus Owner / Founder at BDI technologies
19 August 2023, 01:50
While technically correct, it defeats the purpose of the given variables of the current year and age of the friend. Try to do the math through the code and output the result! :-)
13 February 2023, 11:17
int year=3126; int age=8; System.out.println(year-age);