Class Notes (836,643)
York University (35,328)
ITEC 1620 (35)
Lecture

# FlowchartTutorialSolution.pdf

6 Pages
74 Views

School
Department
Information Technology
Course
ITEC 1620
Professor
Stephen Chen
Semester
Summer

Description
Sample 1: I have a number. Should you guess my numb er, 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: nummyer yoguess 5 3 Higher r e w o L 6 r e h g i H 4 5gYessed. 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: In5poupout. In3put:Output: Higher In6put:Output: Lower In4put:Output: Higher In5put:OutputgYeused. On the page after the flowchart, please onvert the program from the flowchart into JAVA. Flowchart: Start Input my number Input guess Input guess Output: Output: “Higher” “Lower” no yes guess > number yes guess ≠ number no Output: “You guessed my number.” End Program: import java.util.Scanner; public class Sample1 { public static void main( String args [] ) { Scanner scan = new Scanner(System.in); int myNumber = scan.readInt(); int guess = scan.readInt(); while (guess != myNumber) { if (guess > myNumber) System.out.println(“Lower”); else System.out.println(“Higher”); guess = scan.readInt(); } System.out.println(“You guessed my number.”); } } Sample 2: The triangular numbers are as follows: 11
More Less

Related notes for ITEC 1620
Me

OR

Join OneClass

Access over 10 million pages of study
documents for 1.3 million courses.

Join to view

OR

By registering, I agree to the Terms and Privacy Policies
Just a few more details

So we can recommend you notes for your school.