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
35kid Paetrick
Level 3
Kampala
  • 28.06.2019
  • 1070views
  • 6comments

Hi guys, anyone to help me with the below

Question about the task Multiplication table
Java Syntax,  Level 3,  Lesson 6
Under discussion


Display a 10 x 10 multiplication table in the following form:
1 2 3 4 …
2 4 6 8 …
3 6 9 12 …
4 8 12 16 …
…

Requirements:
  • The program should output text.
  • The displayed text should contain 10 lines.
  • Each displayed string must contain 10 numbers separated by spaces.
  • The displayed numbers must form a multiplication table.
package com.codegym.task.task03.task0314; /* Multiplication table */ public class Solution { public static void main(String[] args) { //write your code here int Prod; for(int h=1;h<=10;h++) { System.out.println("\n "); for(int k=1;k<=10;k++) { Prod =h*k; System.out.print(Prod+ " "); } } } }
0
Comments (6)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
Mo
Level 4 , Zurich, Switzerland
28 June 2019, 14:41
As Denise said, ….. public class Solution { public static void main(String[] args) { //write your code here int Prod; for(int h=1;h<=10;h++) { for(int k=1;k<=10;k++) { Prod =h*k; System.out.print(Prod+ " "); } System.out.println(" "); } } }
0
Denise
Level 14 , Delft, Netherlands
28 June 2019, 14:33
I think you should change your System.out.println("\n "); into System.out.print("\n "); and move it below the second for-loop. Because now, you start with 2 new lines.
0
35kid Paetrick
Level 3 , Kampala, Uganda
1 July 2019, 11:53
Thanks, one of the issues has been corrected. Now i have to deal with this "The displayed text should contain 10 lines". Not sure what am doing wrong....!!
0
A. J. Bozdar
Level 4 , Not in list
3 July 2019, 08:22
@Denise: Why are you suggesting learner to use loops to solve this exercise? Whereas loops are of next level.
0
A. J. Bozdar
Level 4 , Not in list
3 July 2019, 08:22
Why use loops when you haven't learnt them yet? Just use Strings and ints to get the exercise done. You are still learning syntax.
0
Denise
Level 14 , Delft, Netherlands
8 July 2019, 11:44
@A. J. Bozdar: I'm not suggesting him to use loops, he already used them. :-)
0
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.