# ITEC 1620 Lecture Notes - Init, Triangular Number, Flowchart

10 views6 pages
Published on 12 Oct 2012
School
York University
Department
Information Technology
Course
ITEC 1620
Professor
Page:
of 6
Sample 1:
I have a number. Should you guess my number, I will say “You guessed my number.”
Otherwise, I will say “Lower” when your guess was too high, and I will say “Higher”
when your guess was too low.
For example:
5 3 Higher
6 Lower
4 Higher
5 You guessed my number.
On the following page, there is a flowchart for a program that will take as input the value
of my number and the value of your guesses, and that will output my response to each
guess.
For Example:
Input: 5 No output.
Input: 3 Output: Higher
Input: 6 Output: Lower
Input: 4 Output: Higher
Input: 5 Output: You guessed my number.
On the page after the flowchart, please convert the program from the flowchart into
JAVA.
Flowchart:
yes no
no
yes
Start
Input my number
guess
number
En
d
Output:
“You guessed my number.”
Input guess
guess >
number
Output:
“Higher”
Input guess
Output:
“Lower”
Program:
public class Sample1
{
public static void main( String args [] )
{
}
}