CSC 120 Lecture 9: For Loops part2

36 views3 pages
Verified Note

Document Summary

This series adds the previous number to the answer: We can code fibonacci series on java using loops (lecture slide 6) This is a program where you get fibonacci series until the n-th number. The loop of the program is on the line(10-17). Line 10: starts the loop for line 2 until the (cid:1684)n(cid:1685)(where user enters) Line 14: prints i, f, fp and fpp. As you can see (cid:1684)f(cid:1685) are the fubonacci numbers in order(2,3,5,8). (cid:1684)fp(cid:1685) is the the number before (cid:1684)f(cid:1685). (cid:1684)fpp(cid:1685) is the number before (cid:1684)fp(cid:1685). This is a game bet between number 1-6. *; //import in scanner public class bettinggamenew public static int determinebetamount( scanner keyboard, int possession ) System. out. println( "you have " + possession + " chips" ); System. out. print( "how many do you want to bet? " int input = keyboard. nextint(); return math. max( 1, math. min( input, possession ) ); public static int determinebettype( scanner keyboard )

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