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
Tay2von
Level 6
Oklahoma City
  • 23.09.2020
  • 407views
  • 2comments

Why am I not passing the last task? My code meets all of the requirements and displays correctly. What am I doing wrong?

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.util.Scanner; import java.io.*; public class Solution { public static void main(String[] args) throws Exception { Scanner scanner = new Scanner(System.in); System.out.println("Enter how many years you plan to take over: "); int age = Integer.parseInt(scanner.nextLine()); System.out.println("Please enter your name: "); String name = scanner.nextLine(); System.out.println(name + " will take over the world in " + age + " years. Mwa-ha-ha!"); } }
0
Comments (2)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
Aditi
Level 7 , Delhi, India
4 January 2021, 18:19
Your code is perfectly alright, but here, you have to follow the Given conditions strictly. You donot have to print these extra lines here, "Enter how many years........" "Please mention your name"
0
Nouser
Level 36 , Germany
23 September 2020, 07:50
Probably cause you output more than the asked line.
+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.