0% found this document useful (0 votes)
35 views

Args Age User - Input: Import Public Class Public Static Void Int New

This Java code uses a Scanner to prompt the user to input their age, stores the input as an integer in the "age" variable, prints the current age, calculates age plus six years and stores it in the "plus_six" variable, and finally prints the future age.

Uploaded by

SOphie Long
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views

Args Age User - Input: Import Public Class Public Static Void Int New

This Java code uses a Scanner to prompt the user to input their age, stores the input as an integer in the "age" variable, prints the current age, calculates age plus six years and stores it in the "plus_six" variable, and finally prints the future age.

Uploaded by

SOphie Long
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

import java.util.

Scanner;
public class Figuring_it_out {
public static void main(String[]args){
int age; // This makes the variable age
Scanner user_input = new Scanner(System.in); // This is making it so that the
computer can read inputs
// basically the thing is "user_input" and it is the keystrokes you make that
java records

inputted

System.out.println("How old are you?"); // asking them to type


age = user_input.nextInt(); // sets age to the next integer (nextInt()) that is

System.out.println("Your age is: " + age + " if you are not lying.");// prints
// the pluses let you add strings and ints to the same line
int plus_six = age + 6; // adds 6 to the number that is age
System.out.println("Your age is: " + plus_six + " six years from now, if you are
not lying."); // prints
}
}

How old are you?


17
Your age is: 17 if you are not lying.
Your age is: 23 six years from now, if you are not lying.

You might also like