CodeGym
Promotion
CodeGym University
Learning
Course
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
sowjanya sripada
Level 2
Hyderabad
  • 18.09.2018
  • 1126views
  • 6comments

whats wrong in my code.

Question about the task Display the square of a number
Java Syntax,  Level 1,  Lesson 3
Resolved

The variable number is given.
Write a program that displays the square of this variable: (number * number).

Requirements:
  • Don't change the variable number. You can only change its value.
  • The program should output text.
  • The displayed text must be a number.
  • The displayed text must be the square of the variable number.
package com.codegym.task.task01.task0140; /* Display the square of a number */ public class Solution { public static int number = 2; public static void main(String[] args) { int square =(2*2); { System.out.println("square"); } } }
0
Comments (6)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
Gaurav bhatt
Level 2 , Delhi, India
28 February 2019, 15:19
/* Display the square of a number */ public class Solution { public static int number = 25; public static void main(String[] args) { System.out.println(number * number); } }
0
Tej M.Reddy
Level 1 , Hyderabad, India
13 October 2018, 12:09
condition no. 3 : output must be a number . line 14: just try to remove double quotes within the parenthesis. suggestion: consider using the variable "number" as in your program it became unused!! :-)
0
jacob sudarsan
Level 3 , Hyderabad, India
9 October 2018, 15:38
in line 12 assign square= number*number and remove quotation marks in println method
System.out.println(square);
0
yanzy050
Level 4 , San Francisco, United States
30 September 2018, 13:47
Who have a Facebook here? I want a team
0
Kumar Abhishek
Level 8 , Sahibganj, India
18 September 2018, 16:43
Save the square in a different variable and then print the variable. x = number*number; S.O.P(x);
0
Khurram
Level 16 , Lahore, Pakistan
18 September 2018, 10:12solution
the output statement should be displaying a number, not the text "square"
+2
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.