CodeGym
Promotion
CodeGym University
Learning
Course
Tasks
Surveys & Quizzes
Games
Help
Schedule
Community
Users
Forum
Chat
Articles
Success stories
Activity
Reviews
Subscriptions
Light theme
Start learning now
  • All questions
Chitransh Derashri
Level 1
Noida
  • 25.10.2018
  • 1130views
  • 4comments

the last condition is not fulfilled in any case.

Question about the task No comments needed
Java Syntax,  Level 0,  Lesson 8
Under discussion

Uncomment one line so that the program displays the numbers 12 and 2 (first 12, and then 2).

Requirements:
  • The program should display the numbers 12 and 2.
  • Don't change the lines that declare variables.
  • The program must have only two int variables.
  • Don't change the lines responsible for screen output.
  • You need to uncomment one line and leave the remaining lines unchanged.
package com.codegym.task.task01.task0107; /* No comments needed */ public class Solution { public static void main(String[] args) { int x = 2; int y = 12; x = x * 3; y = x + y; x = y - x; y = (y - x)/3; System.out.println(x); System.out.println(y); } }
0
Comments (4)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
smile
Level 7 , Tainan, Taiwan, Province of China
30 March 2019, 02:54
Goal: 1. "uncomment" = remove "// " from comment 2. make "x=12" & "y=2" by "uncomment 1 comment"
public class Solution {
    public static void main(String[] args) {
        int x = 2;
        int y = 12;

        // y = x * y;
        y = x + y;

        x = y - x;
        y = y - x;

        System.out.println(x);
        System.out.println(y);
    }
}
0
srikanth
Level 2 , Bangalore, India
10 March 2019, 11:43
public class Solution { public static void main(String[] args) { int x = 2; int y = 12; // y = x * y; y = x + y; x = y - x; y = y - x; System.out.println(x); System.out.println(y); } } bt i did not understand how the value of y=2 changed
+1
Steve Rodgers
Level 2 , Los Angeles, United States
1 November 2018, 05:02
Use "//" to comment out certain lines. Remember, with each line the variable of x and y will change. comment out certain lines until the variable x = 12 and y = 2
0
Khurram
Level 16 , Lahore, Pakistan
26 October 2018, 07:20
you can only remove comments from the lines, you cannot change the code itself (you have changed line 16)
+1
Learn
  • Registration
  • Java Course
  • Help with Tasks
  • Pricing
  • Game Projects
  • 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 Java developer’s career.
Follow us
Interface language
Programmers Are Made, Not Born © 2023 CodeGym
MastercardVisa
Programmers Are Made, Not Born © 2023 CodeGym
This website uses cookies to provide you with personalized service. By using this website, you agree to our use of cookies. If you require more details, please read our Terms and Policy.