JAVA basic comprehensive topic: Write a game program, first output "3,5,10,17,29". Prompt to enter the next number, if the input is correct, the display input is correct, print out all the current numbers and prompt to enter the next number, if the input is incorrect, the display input number is incorrect, please re-enter

eclipse

JAVA Basics Learn to write JAVA code

The question asks you to write a game program that first outputs "3,5,10,17,29." Prompt to enter the next number, if the input is correct, the display input is correct, print out all the current numbers and prompt to enter the next number, if the input is incorrect, the display input number is incorrect, please re-enter

JAVA detailed code and running result details: /** ** /package test8_30; import java.util.Scanner; /** * @author Marin's notebook * Write a game program, first output "3,5,10,17,29". * Prompt for the next number, if the input is correct, * display the input is correct, print out all the current numbers and prompt for the next number, * If the input is incorrect, */public class Test5{public static void main(String [] args){game(); } public static void game(){int[] algorithm= {3,5,10,17,29}; for(int i:algorithm){ System.out.print("\t"+i); } Scanner input=new Scanner(System.in); int num=0; int i=0; While (I < 3) {System. Out. Println (" \ n input the game the next number: "); num=input.nextInt(); if(num==(algorithm[algorithm.length-1]+algorithm[algorithm.length-2]+2)){System.out.println(" Congratulations, correct input! ") ); int[] alg= new int [algorithm.length+1]; for(int j=0; j

The main key is that the JAVA number game is 3,5,10,17,29 "The detailed algorithm is: 5=3+2; 10=5+3+2; 17 = 10 + 5 + 2; 29=10+17+2; 17 + + 2 = 48 29; 48 + 29 + 2 = 80... I hope this algorithm gives you a solution.

The last step of the algorithm analysis

JAVA basic strength topic, comprehensive all the basic knowledge, relatively difficult