95.7k views
4 votes
Each time Kevin re-reads his JAVA book(which happens every month), he learns 10% of whatever material he didn’t know before. He needs to score at least 95% on the comprehensive exam to become a certified JAVA developer. When Kevin’s started, he knew nothing about JAVA . Write a method that simulates Kevin’s learning progress and returns the number of months it will take him to get ready for the exam. Write a main method that displays the result (in years and months).

User Coffeemug
by
5.0k points

2 Answers

5 votes

Answer:

below

Step-by-step explanation:

public class GetMonths {

public static void main(String[] args) {

int noofmonths = 0;

int noofyears = 0;

double percentnotknown = 100;

double percentKnown = 0;

while (percentKnown<95) {

percentnotknown *= 0.9;

percentKnown = 100 - percentnotknown;

noofmonths++;

if (noofmonths==12) {

noofyears++;

noofmonths = 0;

} // end if

} // end while

System.out.println("After "+noofyears+" years, "+noofmonths+" months,");

System.out.println("Percentage known = "+percentnotKnown);

} // end main()

} // end class

User Toxinlabs
by
5.2k points
3 votes

Answer:

The java main method that can be used to display the number of years and months to get ready for the exam is explained below.

Step-by-step explanation:

public class GetMonths {

public static void main(String[] args) {

int noofmonths = 0;

int noofyears = 0;

double percentnotknown = 100;

double percentKnown = 0;

while (percentKnown<95) {

percentnotknown *= 0.9;

percentKnown = 100 - percentnotknown;

noofmonths++;

if (noofmonths==12) {

noofyears++;

noofmonths = 0;

} // end if

} // end while

System.out.println("After "+noofyears+" years, "+noofmonths+" months,");

System.out.println("Percentage known = "+percentnotKnown);

} // end main()

} // end class

User MegaByter
by
4.6k points