Summer 2015 - Lesson 6 Assignments

posted Jul 31, 2015, 8:37 PM by Attila Lengyel   [ updated Jul 31, 2015, 8:44 PM ]
This lesson, we reviewed the syntax of our for loops, a very important piece of programming. We also were introduced to a new tool, the Scanner.

Recall that the for loop is made of three parts, the starting declaration (telling the computer what number to start at), the ending condition (when the condition is false, stop looping), and the step increment (how the loop counts sequentially).
The Scanner allows us to ask the user for input from the user while the program is running. We do this by importing the Scanner object using the line import java.util.Scanner; , creating a Scanner object in main, and then using it to read input.

Assignment 1 will be more of a review of for loops. The code for creating and using a Scanner object has been provided, so study it for use later.
Assignment 2 will ask you to create a Scanner object, and use it to ask the user for TWO numbers. The program will then multiple the two of them, and display the result.
Assignment 3 will introduce a new function of the Scanner, the ability to read a complete line of text from the user. If you are able to complete the program properly, you should be able to provide a number and a string of text, which the computer will repeat as many times as you requested.
Good Luck!
Ċ
Attila Lengyel,
Jul 31, 2015, 8:44 PM
ċ
Attila Lengyel,
Jul 31, 2015, 8:44 PM
ċ
Attila Lengyel,
Jul 31, 2015, 8:44 PM
ċ
Attila Lengyel,
Jul 31, 2015, 8:44 PM
Comments