It has been a while since I downloaded and open the eclipse to code for Java.
We're getting back to Java because we need to recall some of its command and syntax.
I was trying to do some recalling and created a very basic code to run but then in my do while loop the system skips the entering of name and then proceeds to the entering of age in my code if my age is under 18.
Here is my code:
I'm thinking the error is coming from a misplacement or incorrect placement of a structure of the code.
Any help will be appreciated.
Sorry for the disturbance and thanks for reading.
We're getting back to Java because we need to recall some of its command and syntax.
I was trying to do some recalling and created a very basic code to run but then in my do while loop the system skips the entering of name and then proceeds to the entering of age in my code if my age is under 18.
Here is my code:
import java.util.Scanner; public class recall { // Variables static String name; static int age; // Create new Scanner static Scanner input = new Scanner(System.in); public static void main(String[] args) { System.out.println("Welcome to JAVA Total Recall Program."); System.out.print(""); do { // call method intro() intro(); } while (age <= 17); System.out.println("100% COMPLETE"); System.out.println("Starting Step 2..."); } private static void ageCheck() { // age input System.out.println("Enter your age: "); age = input.nextInt(); if (age <= 17) { System.out.println("You are not of legal age to open the JAVA Recall Program."); System.out.println(""); } else System.out.println("Loading next step..."); } private static void intro() { // name input System.out.println("Please enter your FULL name: "); name = input.nextLine(); System.out.print(""); // name output System.out.println("Hello " + name + "! Welcome to JAVA Total Recall Program."); ageCheck(); } }
I'm thinking the error is coming from a misplacement or incorrect placement of a structure of the code.
Any help will be appreciated.
Sorry for the disturbance and thanks for reading.