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
Alex Balandinos
Level 18
Lusaka
  • 29.01.2019
  • 899views
  • 5comments

Hi there. Am getting an error saying the display text should fully match the text given. Ive done everything right so far..just that 1 mistake am making any suggestions will be very helpful.

Question about the task Plan to conquer the world
Java Syntax,  Level 3,  Lesson 8
Under discussion


Enter the number and name from the keyboard. Display the following string:
<name> will take over the world in <number> years. Mwa-ha-ha!

Here's an example:
Kevin will take over the world in 8 years. Mwa-ha-ha!

The order in which the data is input matters a lot.

Requirements:
  • The program should output text.
  • The program must read data from the keyboard.
  • The displayed text must contain the entered name.
  • The displayed text must contain the entered number.
  • The displayed text must fully match the task conditions.
package com.codegym.task.task03.task0318; /* Plan to conquer the world */ import java.io.*; import java.util.Scanner; public class Solution { public static void main(String[] args) throws Exception { //write your code here Scanner scanner = new Scanner(System.in); String name = scanner.nextLine (); int number = scanner.nextInt(); System.out.print(name + " will take over the world in " + number + " years. Mwa-ha-ha!"); } }
0
Comments (5)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
Guadalupe Gagnon
Level 37 , Tampa, United States
29 January 2019, 18:15
sorry, missed this in requirements: "Enter the number and name" change the order of inputs, and include what i said below too.
+2
Alex Balandinos
Level 18 , Lusaka, Zambia
29 January 2019, 17:47
Boss didn't work
0
Alex Balandinos
Level 18 , Lusaka, Zambia
29 January 2019, 17:38
Dude thanks will give a shot
+1
Guadalupe Gagnon
Level 37 , Tampa, United States
29 January 2019, 17:17
need to add this in between lines 14 and 15: scanner.nextLine(); and it will work
0
Guadalupe Gagnon
Level 37 , Tampa, United States
29 January 2019, 17:25
https://stackoverflow.com/questions/13102045/scanner-is-skipping-nextline-after-using-next-or-nextfoo See article for your problem
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.