---
title: "Jam 01 - Exercise 4 - User Input & System Properties"
tags:
- 3 ๐งช in testing
- 4 ๐ฅณ done
- jam01
- java
- io
created: 2025-01-20
updated: 2025-01-20
---
<!-- markdownlint-disable line-length single-h1 no-inline-html -->
<!-- markdownlint-configure-file { "ul-indent": { "indent": 4 }, "link-fragments": {"ignore_case": true} } -->
# Exercise 4 - User Input & System Properties
{%hackmd dJZ5TulxSDKme-3fSY4Lbw %}
## Overview - Exercise 4
In this exercise, you'll learn how to make your programs interactive by getting input from users and accessing system information. You'll use the Scanner class for user input and explore Java's System properties to gather information about the computer running your program. This introduces fundamental concepts of program interaction and system integration that you'll use throughout your programming career.
## Required Steps - User Interaction
Let's use that method, and incorporate some of what you've been learning in zyBooks. Modify your HelloWorld.java program using the following instructions:
1. Instantiate a Scanner object
2. Prompt the user for their name and then storing it in a String object
3. Tell the user the operating system name, architecture, and version (See the API call you explored above!)
4. Output the length of their name
:::warning
๐ง **Common Pitfalls**
- Don't forget to import Scanner
- Always close your Scanner when done
- Remember to use print vs println appropriately
:::
### Example Output - Basic Input and Output
```text
Hello, CSCI 205!
What is your name?
Alice
Here is your operating system info, Alice
OS Name: Mac OS X
OS Architecture: aarch64
OS Version: 15.2
Alice, your name is 5 characters long.
```
## Save Your Work - Exercise 4
Verify what files are uncommited:
```bash
git status
```
Stage your changes (This should be the file shown in `git status` as modified)
Feel free to use a different message as long as it's descriptive
```bash
git add src/main/java/jam01/HelloWorld.java
```
Commit your work
```bash
git commit -m "jam01: Complete user interaction program"
```
Your working directory should be clean.
> ๐ **Checkpoint**: Before continuing, verify:
>
> - Program handles invalid input gracefully
> - System properties display correctly
> - Output matches example format
> - Scanner is properly closed
> - Your changes are committed