Skip to main content
It’s now time to pick up the pace a bit. I’ve got you doing a lot of printing so that you get used to typing simple things, but those simple things are fairly boring. What we want to do now is get you getting data into your programs. This though is a little tricky so we have to have you learn to do two things that may not make sense right away, but if you stick with it they should click suddenly a few exercises from now.Most of what software does is the following:
  1. Take some kind of input from a person.
  2. Change it.
  3. Print out something to show how it changed.
So far you’ve only been printing, but you haven’t been able to get any input from a person, or change it. You may not even know what “input” means, so rather than talk about it, let’s have you do some and see if you get it. Next exercise we’ll do more to explain it.
AskingQuestions.java
Notice that we used print instead of println. This is so that the program doesn’t end the line with a newline and go to the next line.
Ask the user for two words and two numbers, and let the person at the keyboard type in some values, but don’t bother storing their responses into any variables.Again, there is no need to create any variables, except for the Scanner variable typically named keyboard.
Ask the user for their name. Then display their name to prove that you can recall it. Ask them for their age. Then display that. Finally, ask them for how much they make and display that. You should use the most appropriate data type for each variable.
Ask the user for several pieces of information, and display them on the screen afterward as a summary.
  • first name
  • last name
  • grade (classification)
  • student id number
  • login name
  • GPA (0.0 to 4.0) You must use the most appropriate type for each variable and not just Strings for everything.
Ask the user for their name. Then display their name to prove that you can recall it. Ask them for their age. Then display what their age would be five years from now. Then display what their age would be five years ago.
Make a simple numeric calculator. It should prompt the user for three numbers. Then add the numbers together and divide by 2. Display the result. Your program must support numbers with decimals and not just integers.
(This assignment was suggested by Joel H in 2012.)The body mass index (BMI) is commonly used by health and nutrition professionals to estimate human body fat in populations.It is computed by taking the individual’s weight (mass) in kilograms and dividing it by the square of their height in meters.