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
World Expedition
Level 2
Delhi
  • 10.09.2018
  • 1223views
  • 8comments

not able to pass all test cases

Question about the task Pay raise
Java Syntax,  Level 2,  Lesson 2
Under discussion

In the public static void hackSalary(int a) method, increase the salary by 1000 and display the following: "Your salary is: <a+1000> dollars per month."
where <a+1000> is the salary increased by 1000.

Example output for a = 7000:
Your salary is: 8000 dollars per month.

Requirements:
  • The program should display text on the screen.
  • The main method should not call System.out.println or System.out.print.
  • The hackSalary method should not return a result.
  • The main method should call the hackSalary method only once.
  • The hackSalary method should increase the input parameter by 1000 and output text to the screen according to the specified template.
package com.codegym.task.task02.task0205; /* Pay raise */ public class Solution { public static void main(String[] args) { salary(7000); } public static void salary(int a) { int salary; salary=a+1000; a=salary+1000; System.out.println("Your salary is:"+a+"dollars per month."); } }
0
Comments (8)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
Muhammed Akthus
Level 2 , Ernakulam, India
2 May 2020, 02:49
Just code this System.out.println("Your salary is:" +" " +(a+1000)+" " + "dollars per month.");
0
Ali Zahid
Level 5 , Gujrat, Pakistan
17 July 2019, 18:20
Use this one. System.out.println("Your salary is: "+(a+1000)+" dollars per month."); and dont forget to add fullstop at the end..
0
Ashish Mishra
Level 2 , Mumbai, India
16 June 2019, 14:05
To all who are facing problem for last test case you need to print exact output in order to pass: public class Solution { public static void main(String[] args) { hackSalary(7000); } public static void hackSalary(int a) { //write your code here a = a + 1000; System.out.println("Your salary is: " +a+" dollars per month."); } } Note : There has to be same spacing as shown in conditions , n has to be period '.' at the last of the line
0
VikramSingh2710
Level 5 , Noida, India
5 June 2019, 16:51
you don't need to write the 16th line you can just print the "salary" instead of printing "a"
+1
Khurram
Level 16 , Lahore, Pakistan
11 September 2018, 05:53
1. your code is increasing the salary by 2000. Try to adjust it so that it increases only 1000. 2. Make sure the output is the same as in the question, including the given spaces etc.
+1
Jacqueline Lim
Level 9 , Makati, Philippines
10 September 2018, 14:32
The output in the example is different from the given task. In the example, a = 8000, while in the task, a = 7000. Therefore, the output in the task should be "Your salary is: 8000 dollars per month." Another hint: You may just call System.out.println in the salary method. In your case, I suggest that you remove the "int salary" part.
0
Himanshu Pal
Level 3 , Delhi, India
10 September 2018, 12:48
a = a + 1000 so salary 7000 +1000+1000 and you need a code something like this a + 1000
0
World Expedition
Level 2 , Delhi, India
10 September 2018, 14:08
That i have done before same problem occured in that so for simplication according to the question i tried this.
+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.