ITEC 1620 Lecture Notes - Init, Triangular Number

49 views6 pages

Document Summary

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. You guessed my number. my number your guess. 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. 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) else guess = scan. readint(); The series begins with 1 (the first triangular number). To calculate the nth triangular number, n is added to the previous triangular number.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents

Related Questions